Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node-cron run job every 3 hours

I am trying to run a node-cron job every 3 hours and I am not sure if I am doing it right.

Right now I am using:

* * */8 * * *

Is this correct?

like image 593
Bob Avatar asked Jan 11 '17 17:01

Bob


People also ask

How do I run a cron job every 3 hours?

You can set the cron for every three hours as: 0 */3 * * * your command here ..

How do I schedule a script in crontab to run every 5 minutes?

basic 3. /usr/bin/vim. tiny 4. /bin/ed Choose 1-4 [1]: Make a new line at the bottom of this file and insert the following code. Of course, replace our example script with the command or script you wish to execute, but keep the */5 * * * * part as that is what tells cron to execute our job every 5 minutes.


1 Answers

You should zero-out the second and minute values, and use a step of /3. The cron expression for this is

0 0 */3 * * *

Which evaluates to 'At 0 seconds, 0 minutes every 3rd hour'.

Your current expression * * */8 * * * would try to run every second of every minute past every 8th hour.

like image 74
bsyk Avatar answered Oct 01 '22 16:10

bsyk