LoginSignup
18

More than 5 years have passed since last update.

posted at

updated at

cronの実行時間微調整, @reboot

@reboot

  • busybox の crond では @reboot指定が効かないので注意

実行時間微調整

ShellScript - cronを2分,7分,12分...みたいな半端なタイミングで動かす - Qiitaを参考にやってみたところcronが綺麗になってよかった。

しかしこの仕組みを知らない人がみたらわからんだろうなぁ

15,16,17分に実行し、後は17+5分おき
15,16,17-59/5 * * * * date >> ~/test.txt
test.txt
2014年  4月  4日 金曜日 09:15:01 JST
2014年  4月  4日 金曜日 09:16:01 JST
2014年  4月  4日 金曜日 09:17:01 JST
2014年  4月  4日 金曜日 09:22:01 JST
2014年  4月  4日 金曜日 09:27:01 JST
2014年  4月  4日 金曜日 09:32:01 JST
...
0〜4分ずらす例
0-59/5 * * * * date >> ~/0.txt
1-59/5 * * * * date >> ~/1.txt
2-59/5 * * * * date >> ~/2.txt
3-59/5 * * * * date >> ~/3.txt
4-59/5 * * * * date >> ~/4.txt

cronでsudoができない場合

sudo: sorry, you must have a tty to run sudoと出るときは
/etc/sudoersの設定が原因。

- Defaults    requiretty
+ #Defaults    requiretty

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
What you can do with signing up
18