每6小时在linux上运行cron作业

时间:2023-01-31 01:08:50

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

我怎么能每天六小时执行一次命令?尝试了这个无效:

/6 * * * * *  mycommand

5 个解决方案

#1


287  

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

这意味着每6个小时从0开始,也就是0 6 12 18,你可以写成

0 0,6,12,18 * * * /path/to/mycommand

#2


6  

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.

您应该包括一条通往您的命令的路径,因为cron运行的是一个广泛的关闭环境。在交互式shell会话中不会有所有的环境变量。

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.

最好指定到脚本/二进制文件的绝对路径,或者在crontab本身中定义路径。为了帮助调试任何问题,我还将把stdout/err重定向到日志文件。

#3


4  

0 */6 * * * command

0 */6 * * *命令。

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

这将是每天说6小时的最佳方式。

Your command puts for 6 mins.!

你的命令持续6分钟。

Thanks.

谢谢。

#4


0  

0 */6 * * *

0 */6 * * * *

crontab every 6 hours is a commonly used cron schedule.

crontab每6小时为常用的cron计划。

Thanks,

谢谢,

#5


0  

Try:

试一试:

0 */6 * * * command

0 */6 * * *命令。

. * has to

。*必须

#1


287  

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

这意味着每6个小时从0开始,也就是0 6 12 18,你可以写成

0 0,6,12,18 * * * /path/to/mycommand

#2


6  

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.

您应该包括一条通往您的命令的路径,因为cron运行的是一个广泛的关闭环境。在交互式shell会话中不会有所有的环境变量。

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.

最好指定到脚本/二进制文件的绝对路径,或者在crontab本身中定义路径。为了帮助调试任何问题,我还将把stdout/err重定向到日志文件。

#3


4  

0 */6 * * * command

0 */6 * * *命令。

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

这将是每天说6小时的最佳方式。

Your command puts for 6 mins.!

你的命令持续6分钟。

Thanks.

谢谢。

#4


0  

0 */6 * * *

0 */6 * * * *

crontab every 6 hours is a commonly used cron schedule.

crontab每6小时为常用的cron计划。

Thanks,

谢谢,

#5


0  

Try:

试一试:

0 */6 * * * command

0 */6 * * *命令。

. * has to

。*必须