Solarisのrtcコマンドとは?UNIX処方箋

現場ですぐに役立つ知識を欲するあなたに贈る珠玉のTips集。今回は、RTCを利用し時刻を調整するコマンドについての注意点を紹介します。

» 2009年01月19日 08時00分 公開
[ITmedia]

Solarisのcrontabに「rtc」という記載があります(リスト1)。時刻合わせに使えそうなのですが、/usr/sbin/rtcコマンドがありません。これはどのようなものですか?


# The rtc command is run to adjust the real time clock if and when
# daylight savings time changes.
1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1

リスト1 「crontab -l」から該当部分抜粋

/usr/sbin/rtcは、RTC(Real Time Clock)を利用し時刻を調整するためのコマンドで、これはx86版のみのサポートとなっています。おそらくSPARC版をお使いだと思いますが、crontabに設定があるだけでrtcコマンド自体はシステムにインストールされないため、実際には使用できません。

 RTCとは、一般的なPCのマザーボードに搭載されている計時専用チップです。x86版はRTCを使用して1日に1度時刻合わせを実施しています。x86版Solaris 10の場合、RTCの設定は/etc/rtc_configファイルにローカルタイムゾーンとGMT(グリニッジ標準時)からの時間差(秒単位)を表記するという形式になっています(リスト2)。


# This file (/etc/rtc_config) contains information used to manage the
# x86 real time clock hardware. The hardware is kept in
# the machine's local time for compatibility with other x86
# operating systems. This file is read by the kernel at
# boot time. It is set and updated by the /usr/sbin/rtc
# command. The 'zone_info' field designates the local
# time zone. The 'zone_lag' field indicates the number
# of seconds between local time and Greenwich Mean Time.
#
zone_info=Japan
zone_lag=-32400

リスト2 /etc/rtc_configの内容と設定

UNIX関連の悩みなら、「UNIX処方箋」にどうぞ


Copyright © ITmedia, Inc. All Rights Reserved.

注目のテーマ