サーバーの停止/開始/再起動後にcrontabでシェルスクリプトを実行する

サーバーの停止/開始/再起動後にcrontabでシェルスクリプトを実行する

サーバーの再起動時に実行するようにcrontabのシェルスクリプトをスケジュールしたいと思います。サーバーが突然停止またはクラッシュした後、誰かがサーバーを起動したときにも実行する必要があります。

クローンタブではどうしますか?どんなアドバイスでも大きな助けになります。

ベストアンサー1

あなたが何を求めているのかを明確にすることはできますか?ただし、再起動時にcronを実行するには@rebootを使用できます。

人5クローンタップ

These special time specification "nicknames" are supported, which replace the 5 initial  time  and  date
       fields, and are prefixed by the ’@’ character:
       @reboot    :    Run once after reboot.
       @yearly    :    Run once a year, ie.  "0 0 1 1 *".
       @annually  :    Run once a year, ie.  "0 0 1 1 *".
       @monthly   :    Run once a month, ie. "0 0 1 * *".
       @weekly    :    Run once a week, ie.  "0 0 * * 0".
       @daily     :    Run once a day, ie.   "0 0 * * *".
       @hourly    :    Run once an hour, ie. "0 * * * *".

おすすめ記事