Help with cronjob scheduling

Hi Everybody,

How to schedule a job using cron that shouldn't run between working hrs 9am-5pm, while run in non working hrs every hour, every day of the month, month & week.

I tried the following way, not sure I can use logical not operator(!). Please correct me if wrong or suggest other ways which might be better.

crontab -e
0 !9-17 * * * /path/to/script/file

I guess other way is

0 17-8 * * * /path/to/script/file

Thank you in advance

AFAIK, there is no negation operation.

You can try this,

0 0-9,17-23 * * * CMD
1 Like

Thanks for the help