Running cron job on linux every 6 hours

2019-01-07 05:43发布

How can I run command every six hours every day? Tried this not working :

/6 * * * * *  mycommand

5条回答
Ridiculous、
2楼-- · 2019-01-07 05:48

You forgot a * ,and you've too many fields, and it's the hour you need to care about

0 */6 * * * /path/to/mycommand

This means every 6th hour starting from 0, i.e. at hour 0, 6, 12 and 18 Which you could write as

0 0,6,12,18 * * * /path/to/mycommand
查看更多
聊天终结者
3楼-- · 2019-01-07 05:48
0 */6 * * *

crontab every 6 hours is a commonly used cron schedule.

查看更多
我命由我不由天
4楼-- · 2019-01-07 05:51

Try:

0 */6 * * * command

. * has to

查看更多
beautiful°
5楼-- · 2019-01-07 05:59

You should include a path to your command, since cron runs with an extensively cut-down environment. You won't have all the environment variables you have in your interactive shell session.

It's a good idea to specify an absolute path to your script/binary, or define PATH in the crontab itself. To help debug any issues I would also redirect stdout/err to a log file.

查看更多
手持菜刀,她持情操
6楼-- · 2019-01-07 06:01
0 */6 * * * command

This will be the perfect way to say 6hrs a day.

Your command puts for 6 mins!

查看更多
登录 后发表回答