68

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

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

2 Answers 2

127

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___

3
  • why do we need the second line? Why cant we do 07-19 in the first line?
    – Gadam
    May 18, 2021 at 18:32
  • 1
    @Gadam because then it will also run at 19.15, 19.30 and 19.45 h.
    – fedorqui
    May 18, 2021 at 20:42
  • 1
    Nice answer, and special kudos, the reference to crontab.guru is worth real money. Jan 28, 2022 at 0:20
11

Yes, that's correct.

The entry in crontab would should be:

*/15 7-19 * * * /path/script >/dev/null 2>&1
1
  • 10
    a crontab entry without >/dev/null 2>&1 will simply send an email (local email) to root, or the owner of the crontab if it isn't roots crontab. The email will contain the script/program output. That may or may not be desirable.
    – grochmal
    Jan 19, 2017 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.