Topic Options
#1344 - 10/21/01 11:35 PM Chapter K – Advanced scheduling using patterns
Luke Tomasello Administrator Online   content
Member

Registered: 09/17/00
Posts: 739
Loc: San Jose, CA., USA
Here are some examples of CRON specifications.
These specifications are valid for both -start and -stop directives as well as -suspend and -resume.
When we're talking about cron specifications, we're usually speaking in terms of a 24 hour clock.
The fields are as follows: Minute, Hour, Day of the month, Month, and Day of the week
* * * * * #every second
0-59 * * * * #every minute
0 * * * * #on the hour
30 4 * * 1-5 #Mon-Fri at 0430
30 19 * * 2,4,6 #Mon, Wed, Fri at 1930
0 9 25 12 * #Xmas morning at 0900 only

## hello world!
# This example uses a cron specification to print "Hello World!"
# in the console window every Mon, Wed, and Fri at 1930
{
-name HELLO-WORLD

# UNIX cron-style pattern matching
# Lets match Mon, Wed, and Fri at 1930.
-start -cron 30 19 * * 2,4,6 # do whatever script functions you wish to do now
-action -print "Hello World!"
}
_________________________
Regards,
Luke Tomasello

Top
#1345 - 04/05/02 03:01 AM Re: Chapter K – Advanced scheduling using patterns
Luke Tomasello Administrator Online   content
Member

Registered: 09/17/00
Posts: 739
Loc: San Jose, CA., USA
## pattern_cron_test
# This script demonstraits the basics of WinCron 'UNIX cron-style' pattern clauses.
# A pattern clause is used to include or exclude a date/time that matches a pattern
##
# The format of a cron command is very much the V7 standard,
# with a number of upward-compatible extensions.
#
# field allowed values
# ----- --------------
# minute 0-59
# hour 0-23
# day of month 1-31
# month 1-12
# day of week 1-7 (1=Sun, 2=mon, etc..)
#
{
-name pattern_cron_test

# UNIX cron-style pattern matching
# Lets match 8AM on the 1st and 15th of the month.
-start -cron * 8 1,15 * *

# do whatever script functions you wish to do now
-action -print "Hey! It's payday on "%X%
}
_________________________
Regards,
Luke Tomasello

Top
#1346 - 04/21/02 03:22 AM Re: Chapter K – Advanced scheduling using patterns
Luke Tomasello Administrator Online   content
Member

Registered: 09/17/00
Posts: 739
Loc: San Jose, CA., USA
In the preceding examples, we’ve seen how to use the -cron directive to specify a recurring schedule.
Consider the previous example when we fire our job on the 1st and 15th of each month. Now what if we didn’t want to fire this job if it falls on a weekend?

The problem expressed in English would be: I would like to fire a job the 1st and 15th of each month unless that day falls on one of the weekend days; Saturday or Sunday.

In WinCron syntax we express the schedule like this:
{
-name the 1st and 15th, but not Sat or Sun!
-start -cron * 8 1,15 * 2,3,4,5,6
-action -print "Hey! It's payday on "%X%
}


Or we could use an exception clause like this:

{
-name the 1st and 15th, but not Sat or Sun!
-start -cron * 8 1,15 * *
-action -onerror break
-action -match -cron -except * * * * 1,7
-action -print "Hey! It's payday on "%X%
}


The -onerror directive simply tells WinCron that if there is an exception to break from the current job without executing any further statements. However, the job remains active and will be rescheduled for the next qualifying date.

Either of these jobs will have the desired effect. However, exception clauses become important when the number of exceptions would either be impossible to write in the -start trigger directly, or utterly impossible to understand.
_________________________
Regards,
Luke Tomasello

Top


Moderator:  Luke Tomasello