Crontab runs every 3 hours

crontab runs every 3 hours

  • 3 / sh / home/test.sh

in this case, I saved it at 8 o"clock, so will it run at 9 o"clock?
what time is it every 3 hours?

Mar.09,2021

m h dom mon dow command

this is displayed when you open crontab. Explain

m:0-59
h:0-23
dom:1-31
mon:1-12
dow:0-60
command:

the first one represents the minute, so the first one is written casually to indicate the minute of execution

.

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

.
1 */3 * * * php /path/to/your/cron.php        
3

how do you understand each here? There is no difference between * / 1 and * , so it can be omitted. Think about it here. * / 3 indicates the time it takes to be divisible by 3.

I wrote a blog before. You can take a look at it: use Crontab to execute PHP files regularly under Ubuntu


9 o'clock is run, which starts at 0 o'clock in 24 hours every 3 hours. 0,3,6,9,12, . And so on.
here is an example:
what is used at regular intervals in the crontab of linux


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

this is executed every 3 hours. You can test it by yourself, for example, echo time to a file

.
Menu