367 文字
2 分
計画停電の時に実行すべきLinuxコマンド
atコマンド
以下のコマンドでスケジュールできる。
# at -t '200702100700'at> shutdown -h nowCtrl+D予定を確認する場合は以下のコマンド。
# atq# shutdown -h timeを実験してみました。
Linuxの場合は、timeのフォーマットが3種類ある。
- now: すぐに
- +x: x秒後にシャットダウン
- hh
: 次回のhh時mm分
日付指定はできないから、ある時間にシャットダウンしたい場合は3番目を利用する。
3番目をシェルプロンプトへ利用すると、プロンプトが帰ってこないでシャットダウンが開始するまでずっとブロックされてしまいます。リモートから時間指定でシャットダウンをする場合はずっと接続しっぱなしにしなければならないのでscreenなどを使ってでシェルを立ち上げっぱなしにしておかなければなりません。
また、定期的にシャットダウン予定までのアラートが標準出力に出るようです。(ちょっとびびる)
# /sbin/shutdown -h 12:00automatically shutdown process now begin.Broadcast message from root (pts/1) (Wed Apr 2 16:00:40 2008):The system is going DOWN for system halt in 1200 minutes!Broadcast message from root (pts/1) (Wed Apr 2 17:00:40 2008):The system is going DOWN for system halt in 1140 minutes!Broadcast message from root (pts/1) (Wed Apr 2 18:00:40 2008):The system is going DOWN for system halt in 1080 minutes!Broadcast message from root (pts/1) (Wed Apr 2 19:00:41 2008):The system is going DOWN for system halt in 1020 minutes!Broadcast message from root (pts/1) (Wed Apr 2 20:00:41 2008):The system is going DOWN for system halt in 960 minutes!..... 計画停電の時に実行すべきLinuxコマンド
https://blog.teraren.com/posts/shutdown-at/