Will crontab hour range ab work after b too?

Say I have a crontab that runs every 20 minutes, and I have a range of hours that can vary, so say ab , which in one example might look like

 */20 5-23 * * * /usr/bin/cool_program 

My question is: will cron work at 23:00, 23:20, 23:40 and 00:00?

+4
source share
2 answers

Yes, it will run every 2 minutes from 5am to 11pm,

 * 20 – 20th Minute (Top of the hour) * 5-23 – 5.20 am,5.40 am,6 am,....23 pm * * – Every day * * – Every month * * - EvryDay of the Week 

Help Documentation

+4
source

GK27's answer does not fully answer the question, so let me clarify:

cron will run jobs when the time matches the provided expression. Your expression says that it should work when the minute is divided by 20 ( */20 ), and your time range says that it should work when the hour is in the specified range inclusive ( 5-23 ). The other three * say that they correspond to any day, month and year.

Therefore, the first task will be executed at 05:00, because the hour, 05 , is in the range from 5 to 23, and the minute, 00 , is divided by 20. The last job will work at 23:40 because hour 23 is in the range from 5 to 23, and the minute 40 is divided by 20. It will not work at 00:00, because hour 00 not in the range 5 to 23.

+5
source

Source: https://habr.com/ru/post/1478914/


All Articles