0

Set Date on Linux

วันนี้นั่งหาข้อมูล set date อยู่พักนึง งงมากว่าทำไม busy box กะ debian เค้าถึง set ไม่เหมือนกัน(จริงๆ งง มานานแล้วแต่ไม่มีเวลานั่งหา) สุดท้ายก็ได้แหล่งความรู้จากทีนี่ครับ

■ CAT709/// debianのdateコマンドとbusybox ….
debianのdateコマンドとbusybox の組み込みdateコマンドの書式が違うので戸惑う。busyboxのdateコマンドの-sオプション(SET)の書式がわからなかったので結局ソースを見て判明した。

} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d:%d",
                                          &t.tm_year,
                                          &t.tm_mon,
                                          &t.tm_mday,
                                          &t.tm_hour,
                                          &t.tm_min, &t.tm_sec) == 6) {

と、ソースに書いてあった。デリミタは . と – だ。つまり

# date -s "2003.2.7-22:45:00"
Fri Feb  7 22:45:00 UTC 2003
# hwclock --systohc
# hwclock
Fri Feb  7 22:45:09 2003  -0.719862 seconds

おっけー