How do I disable cronjob for particular time interval - cron

I have a cronjob that run every mins daily. I have a requirement to stop it from particular time eg: 2pm on Saturday till 10am Monday. How can this be implemented

You should define explicit the time when you want to be run. And because of timeframe this can't be done by one line. Something like can do the job:
* * * * 2-5 /path/to/script
* 0-13 * * 6 /path/to/script
* 10-23 * * 1 /path/to/script
first line will run it every minute from Tuesday to Friday
second line will run it every minute till 14h on Saturday
third line will run it every minute starting from 10h on Monday

Related

Cron schedule expression for running every 30 mins for first 7 days of every month, every two hours after that

So far I have this: 0 */30 0 1,2,3,4,5,6,7 * ? but not sure how to express every two hours after that.
It would look something like that:
*/30 * 1-7 * * command
* */2 8-31 * * command
Where the first cron runs every 30 minutes for the first 7 days of the month, and the second one runs every 2 hours from day 8 onwards.

modify a cronjob to make it run every half an hour starting next month

I have the following cronjob which runs every 30 min, and i want to change it to make it run every half an hour starting from next month(September). I need to change it because it is overriding some changes I am doing
0,30 * * * * /usr/bin/iga-chef-client -s 2 >> /var/chef...
should it be this way:
0,30 * * 9 *.....
this runs every 30 minutes starting from the month of September, but i am not sure if it is the correct way to put it.
Thanks in advance

Cron expression for 24 hour period

I'm trying to write a crontab expression that will begin a specified period of time and run on an interval for a 24 hour period. For example I want the job to run every Thursday beginning at 4 PM and repeat every hour for 1 day. Is there a way to do this? Everything I have tried stops at the end of the day Thursday.
You need two crontab entries, one for the occurrences on Thursday and one for the occurrences on Friday.
For example (I have not tested this):
0 16-23 * * 4 your_command
0 0-15 * * 5 your_command
The fifth column is the day of the week, with Sunday=0. (Vixie cron also lets you specify the day of the week by name.)

How to make cron job to run every 15 minutes on Thursday starting at 4pm?

What would be the line in crontab to run some script every 15 minutes starting at 4pm every Thursday, until the midnight? How to modify it to run until Friday 11am?
I don't think it is possible to do what you need on a single line, even just the Thursday piece, because you require the last execution to happen at midnight (which is technically Friday). Here are the 2 lines that would do all you described:
*/15 16-23 * * 4 command
*/15 0-11 * * 5 command
First line is for the Thursday piece, which will run every 15 mins from 4 PM to 11:45 PM.
The second line runs on Friday's from midnight until 11 AM, also every 15 mins.

How to skip saturday and sunday in a cron expression?

Hi I want to create a cron expression excluding saturday and sunday.
Begin the line with 0 0 * * 1,2,3,4,5 <user> <command>. The first fields are minutes and hours. In this case the command will run at midnight. The stars mean: for every day of the month, and for every month. The 1 to 5 specify the days. monday to friday. 6=saturday 0=sunday.
Try this:
# run every two hours at the top of the hour Monday through Friday
0 */2 * * mon-fri <command>

Resources