last reboot
last rebootを実行すると、Macの起動日時を新しい順に一覧表示できる。
$ last reboot
reboot time 火 11月 10 18:51
reboot time 木 10月 22 18:03
reboot time 水 10月 7 06:27
reboot time 土 10月 3 11:50
reboot time 土 10月 3 09:36
wtmp begins 2026年 10月 3日 土曜日 09時36分34秒 JST
lastはログイン履歴を表示するコマンドである。
rebootは再起動のたびに記録される擬似的なユーザー名である。
rebootを引数に指定すると、起動の記録だけを表示する。
最終行のwtmp beginsは、記録に残っている最古の日時を示す。
最古の日時より前の再起動は表示されない。
参考: 【Linux】lastコマンドでログイン履歴を確認する
Linuxのlastとの違い
macOSのlastはBSD由来のコマンドであり、Linux(util-linux)のlastとは出力やオプションが異なる。
起動日時だけが表示される
Linuxのlast rebootは起動から停止までの稼働時間も表示する。
reboot system boot 6.8.0-45-generic Mon Jul 20 05:51 - 23:10 (4+17:18)
macOSのlast rebootはreboot timeと起動日時だけを表示する。
稼働時間やカーネルのバージョンは表示されない。
shutdownの記録は表示されない
Linuxではlast -x shutdownでシステム停止の履歴を表示できる。
macOSのlastには-xオプションがない。
last shutdownを実行しても停止の履歴は表示されない。
$ last shutdown
wtmp begins 2026年 10月 3日 土曜日 09時36分34秒 JST
引数なしのlastにも停止の記録は現れない。
再起動で中断したセッションはcrashと表示される
lastを引数なしで実行すると、ログイン履歴に起動の記録が混ざって表示される。
再起動の直前までログインしていたセッションは、ログアウト日時の部分がcrashと表示される。
$ last
...
reboot time 火 11月 10 18:51
root console 火 11月 10 18:45 - crash (00:05)
...
crashは、ログアウトの記録がないまま次の起動を迎えたセッションを表す。
オプション
年も表示する(-y)
デフォルトの表示には年が含まれない。
-yを付けると起動日時に年も表示する。
$ last -y reboot
reboot time 火 11月 10 2026 18:51
reboot time 木 10月 22 2026 18:03
reboot time 水 10月 7 2026 06:27
reboot time 土 10月 3 2026 11:50
reboot time 土 10月 3 2026 09:36
wtmp begins 2026年 10月 3日 土曜日 09時36分34秒 JST
表示件数を絞る(-n)
-nで表示する件数を指定できる。
$ last -n 3 reboot
reboot time 火 11月 10 18:51
reboot time 木 10月 22 18:03
reboot time 水 10月 7 06:27
wtmp begins 2026年 10月 3日 土曜日 09時36分34秒 JST
JSONで出力する(–libxo)
--libxo jsonを付けるとJSON形式で出力する。
ただしlogin-timeは表示用の文字列であり、デフォルトでは年を含まない。
年も必要な場合は-yと組み合わせる。
$ last --libxo json reboot
{"last-information": {"last": [{"user":"reboot time","login-time":"火 11月 10 18:51"}, {"user":"reboot time","login-time":"木 10月 22 18:03"}, {"user":"reboot time","login-time":"水 10月 7 06:27"}, {"user":"reboot time","login-time":"土 10月 3 11:50"}, {"user":"reboot time","login-time":"土 10月 3 09:36"}],"utxdb":"wtmp","begins":"2026年 10月 3日 土曜日 09時36分34秒 JST"}}
jq(macOS 15以降は標準で入っている)を使えば、起動日時だけを取り出せる。
$ last --libxo json reboot | jq -r '.["last-information"].last[]["login-time"]'
火 11月 10 18:51
木 10月 22 18:03
水 10月 7 06:27
土 10月 3 11:50
土 10月 3 09:36
現在の起動日時だけを確認する
直近の起動日時だけを知りたい場合はsysctl kern.boottimeでも確認できる。
$ sysctl kern.boottime
kern.boottime: { sec = 1794304260, usec = 704559 } Tue Nov 10 18:51:00 2026
uptimeでは起動からの経過時間を確認できる。
$ uptime
18:43:39 up 3 days 23:52, 10 users, load average: 6.29, 5.39, 4.61
動作確認した環境
macOS 27.2.1で動作を確認した。
参考
man last- 【Linux】uptime -sでシステムの起動時刻を表示する
