以下の内容はhttps://dk521123.hatenablog.com/entry/2021/04/01/160946より取得しました。


【Linux】cron / crontab 〜 あれこれ編 〜

■ はじめに

https://dk521123.hatenablog.com/entry/2016/10/25/230650
https://dk521123.hatenablog.com/entry/2019/11/29/221207

の続き。

今回は、cron / crontabに関するTipsをまとめる。

目次

【1】viを指定する
【2】時間をランダムにずらして実行する
【3】特定の時間を除外する

【1】viを指定する

http://blog.dacelo.info/linux/entry-939.html

EDITOR=vi
export EDITOR

【2】時間をランダムにずらして実行する

例:毎日午前4時の0~60分(= 60 x 60[秒] = 3600[秒])の間に 【実行したいコマンド】 を実行する

0 4 * * * sleep `expr $RANDOM \% 3600`; 【実行したいコマンド】

参考文献
http://za.toypark.in/html/2006/05-28.html
http://uguisu.skr.jp/Windows/crontab.html
http://tips.recatnap.info/wiki/Cron%E3%82%92%E6%8C%87%E5%AE%9A%E6%99%82%E9%96%93%E3%81%AE%E3%83%A9%E3%83%B3%E3%83%80%E3%83%A0%E3%81%A7n%E7%A7%92%E5%BE%8C%E3%81%AB%E5%AE%9F%E8%A1%8C

 【3】特定の時間を除外する

例:5分ごとに実行を。ただし、3時は除く。

#  「,」「-」を駆使して、指定する

*/5 0-2,4-23 * * * ~/hello.sh

参考文献
https://hacknote.jp/archives/29685/  

関連記事

 cron / crontab 〜 入門編 〜
https://dk521123.hatenablog.com/entry/2016/10/25/230650
 cron / crontab 〜 基本編 〜
https://dk521123.hatenablog.com/entry/2017/08/20/184005
 AWS Glue ~ 基本編 /トリガ ~
https://dk521123.hatenablog.com/entry/2019/11/29/221207




以上の内容はhttps://dk521123.hatenablog.com/entry/2021/04/01/160946より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14