サーバの日時を修正 †
文字列 指定した文字列を表示する %H 時 (00~23) %I 時 (01~12) %k 時 ( 0~23) %l 時 ( 1~12) %M 分 (00~59) %p AM あるいは PM のロケール(国や地域に合わせた文字列) %r 12時間形式の時刻 (HH:mm:ss [AP]M) %s 1970-01-01 00:00:00 UTC からの秒数 %S 秒 (00~61) %T 24時間形式の時刻 (HH:mm:ss) %a ロケールによる省略形の曜日の名前 (Sun~Sat) %A ロケールによる完全に表記した曜日の名前(Sunday~Saturday) %b ロケールによる省略形の月の名前 (Jan~Dec) %B ロケールによる完全に表記した月の名前(January~December) %c ロケールによる日付と時刻 (Sat Nov 04 12:02:33 EST 1989) %d 日(月内通算日数) (01~31) %D 日付 (MM/DD/YY) %j 年内通算日数 (001~366) %m 月 (01~12) %w 週のうちの曜日(0~6)で0が日曜日に対応 %x ロケールによる日付の表現 (MM/DD/YY) %y 西暦の下2けた (00~99) %Y 年 (1970~) シェル等で使用する具体例
ntpdateを使って、強制的にntpサーバと時刻を同期させたい場合は # ntpdate 192.168.0.1 SuSEでntpdateを使用すると、ntpdateは推奨していません。と怒られる。 !!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!! The ntpdate program is deprecated and should not be used any more. To quote the upstream ntp developers: "The functionality ntpdate offered is now provided by the ntpd daemon itself. If you call ntpd with the command line option -q it will retrieve the current time and set it accordingly." Please check the Network Time Protocol (NTP) daemon man page and http://support.ntp.org/bin/view/Dev/DeprecatingNtpdate for further information. You can replace the ntpdate call with "rcntp ntptimeset" to achieve an inital poll of the servers specified in /etc/ntp.conf. The program /usr/sbin/sntp offers comparable functionality to ntpdate. Specifically sntp -P no -r pool.ntp.org is equivalent to ntpdate pool.ntp.org For further details please refer to the man page of sntp. sntpがあるのでそれを使いなさい、と言われる。 使い方はここを確認。 日時の取得 †現在の日時をYYYYMMDD形式で取得 †# date +%Y%m%d 時刻まで出したい # date +%Y%m%d%H%M%S 昨日の日付を取得したい †# date -d "1 days ago" "+%Y%m%d" ちなみにFreeBSDの場合は # date -v-1d +"%Y%m%d" 翌日の日付を取得したい †# date -d "1 day" "+%Y%m%d" |