4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macの時刻をターミナルから設定

Last updated at Posted at 2018-10-02

Mac OS Xの時刻をターミナルから設定する

Macの時刻が自動で同期されないので手動でコマンド一発で設定するワンライナーをメモ

NTPでの時刻同期は事前に環境設定でOffにするか、sudo systemsetup -setusingnetworktime Offをする

# 日付の再設定
date -r "$(wget -q https://ntp-a1.nict.go.jp/cgi-bin/jst -O - | sed -n 4p | cut -d. -f1)" "+%m:%d:%y" | xargs -IDATE sudo systemsetup -setdate DATE

# 時刻の再設定
date -r "$(wget -q https://ntp-a1.nict.go.jp/cgi-bin/jst -O - | sed -n 4p | cut -d. -f1)" "+%H:%M:%S" | xargs -ITIME sudo systemsetup -settime TIME

wgetがない場合にはcurlを使えばOK!
これで一発!!

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?