linux - crontab 每3个小时运行一次
PHPz
PHPz 2017-04-17 16:03:26
0
2
1228

crontab 每3个小时运行一次

  • 3/ sh /home/test.sh

这种情况,我保存时在8点,那么9点就会运行吗?
他这个每3个小时,是 什么时间点 的3个小时???

PHPz
PHPz

学习是最好的投资!

reply all(2)
Ty80
m h dom mon dow command

This is what is displayed when you open crontab, please explain

m:分钟,0-59
h:小时,0-23
dom:日期,1-31
mon:月份,1-12
dow:星期,0-6,0为星期天
command:命令

The first one represents the minute, so you can just write the first one to indicate the minute to execute it

All you have to do is limit the second parameter, hours

1 */3 * * * php /path/to/your/cron.php        
每隔3小时的第一分钟执行一次任务

How do you understand the word "every" here? */1*无区别,所以可以省略。这里可以想想,*/3It’s easier to understand if it means a time divisible by 3.

I blogged about it before, you can take a look: Using Crontab to execute PHP files regularly under Ubuntu

迷茫
$ crontab -e
1 */3 * * * commands

This is executed every 3 hours. You can test it by yourself on how to execute it. For example, echotime to a file

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template