How to skip saturday and sunday in a cron expression? - linux

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>

Related

Rundeck: Schedule from from Sunday Morning until Friday Afternoon

I have a Rundeck job that I would like to schedule to run from Sunday at 10 am to Friday at 17:00.
I could create three separate instances of the job and schedule it as below:
#every Sunday starting at 10 until midnight
0 */15 10-23 ? * 1
# every fifteen minutes starting on Monday midnight to Thursday 11:59 am
0 */15 * ? * 2-5 *
#every Friday starting at 12 am until 17:00 pm
0 */15 00-17 ? * 6
But it seems like there has to be a better way that will allow me to do this in one job. Any ideas? Thanks in advance.
The easiest way to do that is with Calendars feature (Enterprise), you can assign each rule to a single job. Take a look at this.

Cron expression to run all the time except every Sunday 10am to 3pm

I need to suppress AppDynamics alerts on every Sunday between 10ma to 3pm and remaining all the time, they should run. To achieve this, i need to write a croj expression to satisfy the condition of "run all the time except every Sunday 10am to 3pm". what could be the cron expression for this ?
You can create a cron job to run from Monday to Saturday, here for each hour:
0 * * * mon-sat
And another to cover the interval you want on Sunday, here one by one hour from 10:00 AM to 03:00 PM:
0 10-15/1 * * sun

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.)

can't get the right cron job timing

i'm trying to do some stuff automatically every 8 Weeks, so i had open a new user crontab like this one:
crontab -e
0 9 * */2 1-5 do_this_stuff
# do it every 2 month on monday till friday at 9:00 am
This should do the job every 2 month on monday till friday on 9:00 am, but i does not. It is doing the job evey week once. Don't get it. What i'm doing wrong?
Running System is a latest debian.
regarding http://wiki.ubuntuusers.de/Cron it should run fine
The Anwer is, cron can't do a job randomly on a random day in a month. I had to change my crontab to: 0 9 1 */2 * do_sm_stuff -- this runs every two Month always on the first Day in a Month
thank you Igor

dont understand cron. What is 56 11 * * * /usr/sbin/update-file.sh

What does this command mean in cron? How often will this run? When will it run? Will it run daily?
56 11 * * * /usr/sbin/update-file.sh
From crontab(5):
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
Thus, your line means to run /usr/sbin/update-file.sh every day at 11:56 AM.
Crontab format is: minute, hour, day of month, month, day of week, command.
So this will run /usr/sbin/update-file.sh at 11:56 AM every day.

Resources