Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

crontab run every 15 minutes between certain hours

Is this correct scheduled to run between 07:00 and 19:00 at every 15 minutes?

*/15    07-19        *     * *     /path/script 
like image 373
catalin Avatar asked Jan 19 '17 14:01

catalin


People also ask

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.


2 Answers

Your command is fine!

To run from 7.00 until 19.45, every 15 minutes just use */15 as follows:

*/15    07-19        *     * *     /path/script ^^^^    ^^^^^ 

That is, the content */15 in the minutes column will do something every 15 minutes, while the second column, for hours, will do that thing on the specified range of hours.

If you want it to run until 19.00 then you have to write two lines:

*/15    07-18        *     * *     /path/script 0          19        *     * *     /path/script 

You can have a full description of the command in crontab.guru: https://crontab.guru/#/15_7-19___

like image 72
fedorqui 'SO stop harming' Avatar answered Oct 05 '22 23:10

fedorqui 'SO stop harming'


Yes, that's correct.

The entry in crontab would should be:

*/15 7-19 * * * /path/script >/dev/null 2>&1 
like image 38
Sion Williams Avatar answered Oct 06 '22 01:10

Sion Williams