LoginSignup
17
18

More than 5 years have passed since last update.

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

Last updated at Posted at 2014-04-04

@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
17
18
2

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
17
18