Topic Options
#1349 - 10/05/01 05:47 AM Scheduling a batchjob to run every first weekday of a month
Anonymous
Unregistered


Hi there,

I would like to run a batchjob every first weekday of a month.
Struggling for a while with scripts didn't help.
Can anyone help me out?

Top
#1350 - 10/21/01 05:40 PM Re: Scheduling a batchjob to run every first weekday of a month
Luke Tomasello Administrator Offline
Member

Registered: 09/17/00
Posts: 740
Loc: San Jose, CA., USA
Hi Jelle.

I am releasing version 3.2 that has a pattern-matching engine that will do exactly what you want.

You are welcome to test out the beta, or you can wait for the release within a couple days as soon as testing is done.

Reply if you would like the beta version.
_________________________
Regards,
Luke Tomasello

Top
#1351 - 10/22/01 02:13 PM Re: Scheduling a batchjob to run every first weekday of a month
Luke Tomasello Administrator Offline
Member

Registered: 09/17/00
Posts: 740
Loc: San Jose, CA., USA
Jelle,

I've released the version to "run a batchjob every first weekday of a month."

You can get it here .
The new directive is the -match directive.
Let me know if you need any help getting the script to do what you want.
_________________________
Regards,
Luke Tomasello

Top
#1352 - 11/04/01 08:43 PM Re: Scheduling a batchjob to run every first weekday of a month
Luke Tomasello Administrator Offline
Member

Registered: 09/17/00
Posts: 740
Loc: San Jose, CA., USA
Here's the program to fire the first weekday of each month.

## event_test.tg
# This script demonstrates advanced pattern matching using -match and
# the event directives: -setevent, -clearevent, and -checkevent.
# This script will perform its work only the first weekday of each month.
# What is interesting is that -match doesn’t know about only doing things
# once, therefore we use events to signal when we have run once,
# then reset the event once we no longer match.
##

## event_cleanup
# simple one-time job to reset event on startup
{
-name event_cleanup
-start
-action -clearevent been_here
-stop
}

## event_test
# main worker job to test the current date/time each day at 8 AM
# we are testing to see if the current date is the first weekday in a month
# if match TRUE, follow the true branch
# if match FALSE, follow the false branch
{
-name event_test
-start -time 08:00:00 AM
-action -onerror false_branch
-action -match -cron * * 1,2,3 * 2-6
-action -call true_branch
-action -inc 1 0 0 0
}

## true_branch
# If we get here and been_here=false
# 1. **do main work**
# 2. set event been_here=true
# if we get here and been_here=true
# 1. we will break from this routine (and in caller)
{
-name true_branch
-action -onerror break
-action -checkevent been_here
-action -print "Matched first weekday of the month at " %X%
-action -print "** do stuff here **"
-action -setevent been_here
}

## false_branch
# 1. clear the event
# 2. return to caller (and break from routine)
{
-name false_branch
-action -clearevent been_here
-action -return break
}
_________________________
Regards,
Luke Tomasello

Top


Moderator:  Luke Tomasello