「hwclock」コマンドは現地時間に正のオフセットを適用しますが、「date」コマンドは現地時間に負のオフセットを適用するのはなぜですか。

「hwclock」コマンドは現地時間に正のオフセットを適用しますが、「date」コマンドは現地時間に負のオフセットを適用するのはなぜですか。

タイムゾーンの使用にはいくつかの問題があります。誰かが私にこの結果を説明できますか?このhwclockコマンドが現地時間に正のオフセットを適用し、このdateコマンドが負のオフセットを適用するのはなぜですか。

$> export TZ=BRA+2
$> date
Tue Jan 31 18:22:45 BRA 2017
$> date -u
Tue Jan 31 20:22:48 UTC 2017
$> hwclock --systohc
$> hwclock -l
Tue Jan 31 18:23:04 2017  0.000000 seconds
$> hwclock -u
Tue Jan 31 16:23:12 2017  0.000000 seconds
$> hwclock --systohc --utc
$> hwclock -l
Tue Jan 31 20:23:31 2017  0.000000 seconds
$> hwclock -u
Tue Jan 31 18:23:34 2017  0.000000 seconds

ベストアンサー1

-l私はあなたの混乱が-uforの使用にあると思いますhwclock

hwclockコマンドで--utcまたは--localtimeオプションを使用しても、ハードウェアクロック時間がUTCまたはローカル時間で表示されるわけではありません。

これは実行時に次のことを意味します。

hwclock -u

時間をutc形式で表示する代わりに、hwclockをUTC形式として解釈するか、その逆に解釈するようにシステムに指示します-l

マニュアルページから:

-u, --utc
--localtime
Indicates that the Hardware Clock is kept in Coordinated Universal
Time or local time, respectively. It is your choice whether to keep
your clock in UTC or local time, but nothing in the clock tells
which you've chosen. So this option is how you give that information
to hwclock. If you specify the wrong one of these options (or
specify neither and take a wrong default), both setting and querying
of the Hardware Clock will be messed up.

If you specify neither --utc nor --localtime , the default is whichever
was specified the last time hwclock was used to set the clock (i.e.
hwclock was successfully run with the --set, --systohc, or --adjust
options), as recorded in the adjtime file. If the adjtime file
doesn't exist, the default is local time.

源泉)

おすすめ記事