In the previous chapter we talked about executing external programs.
In this chapter we will talk about day skipping.
For the purposes of this example, we will reuse the job we had developed in Chapter 1, “Hello World!”
# Reschedule job to run every day
{
# Name our job
-name my job
# Start now and increment the day field.
# This will cause the job to fire NOW and tomorrow at the same time
-start -inc 1 0 0 0
# Print Hello World!
# (Or do whatever real work you wish)
-action -print "Hello World!"
}
What we know, is that this job will start immediately, then begin printing "Hello World!" once every day.
What we would like to do is to exclude job execution on certain days.
This is accomplished with the -skip directive.
-skip [-week days] | [-year days ]
A -skip directive tells WinCron to 'skip' the specified days.
-skip -week nn
Means SkipDaysOfTheWeek where: 1=Sun, 2=Mon, ..., 7=Sat.
Days may be separated by commas and or spaces.
-skip -year
Means SkipDaysOfTheYear: Days since start of year, Jan 1 = 1.
So, to skip say, Saturday and Sunday, we would simply add a -skip directive like the following:
# Reschedule job to run every day, yet skipping Saturday and Sunday
{
# Name our job
-name my job
# Start now and increment the day field.
# This will cause the job to fire NOW and tomorrow at the same time
-start -inc 1 0 0 0
# Skip Saturday and Sunday
-skip -week 7,1
# Print Hello World!
# (Or do whatever real work you wish)
-action -print "Hello World!"
}
In addition to skipping week days, you can also skip year days.
Lets setup our job to skip January 1 of any year.
# Reschedule job to run every day, yet skipping Saturday and Sunday
# Also never run on January 1 of any year
{
# Name our job
-name my job
# Start now and increment the day field.
# This will cause the job to fire NOW and tomorrow at the same time
-start -inc 1 0 0 0
# Skip Saturday and Sunday
-skip -week 7,1
# Also never run on January 1 of any year
# Remember, the ‘1’ here is the ‘year day’
-skip -year 1
# Print Hello World!
# (Or do whatever real work you wish)
-action -print "Hello World!"
}
_________________________
Regards,
Luke Tomasello