1
0

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 1 year has passed since last update.

Linuxで指定時刻・指定時間後に再起動・パワーオフする

Last updated at Posted at 2022-10-25

はじめに

  • Linuxで指定時間、あと5分後にシャットダウンしたい、リブートしたい、といったときにやる方法です
  • 夜間に再起動したいけど、ターミナルは切断しちゃうし、cron? nohup? なにが簡単?
  • 今から1時間ぐらいあとに再起動したいけどどうしたらいいだろうか

at コマンドを使う

  • 再起動は reboot 、シャットダウンは poweroff

1分後

$ at now + 1 min
at> sudo reboot
Ctrl + D
at> <EOT>
job 1 at Tue Oct 25 23:01:10 2022

1時間後に再起動

$ at now + 1 hour
at> sudo reboot
Ctrl + D
at> <EOT>
job 1 at Tue Oct 25 23:10:10 2022

23:30に再起動

$ at 23:30
warning: commands will be executed using /bin/sh
at> sudo reboot
Ctrl + D
at> <EOT>
job 1 at Tue Oct 25 23:30:00 2022

2022/10/25 23:30に再起動

$ at -t '202210252330'
warning: commands will be executed using /bin/sh
at> sudo reboot
Ctrl + D
at> <EOT>
job 1 at Tue Oct 25 23:30:00 2022

確認

$ atq
1	Tue Oct 25 23:02:00 2022

詳細を確認

$ at -c 1

解除

$ at -d 1

さいごに

かんたんでしたね

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?