Topic Options
#1347 - 12/04/01 05:05 AM run a job each sunday
rgroetz Offline
Junior Member

Registered: 12/01/01
Posts: 12
Hi there,
I would like to run a batchjob every sunday
and another job each 21st on 10pm. of a month.

Can anyone help me out?

rudolf

Top
#1348 - 12/04/01 09:28 AM Re: run a job each sunday
Luke Tomasello Administrator Offline
Member

Registered: 09/17/00
Posts: 740
Loc: San Jose, CA., USA
Not a problem.
I had to make some assumptions about what you wanted because it wasn't called out.
However, if I got it wrong, you should be able to make the changes (or I can help)

First, here is what I assumed:
1. The task you wanted to carry out on each Sunday and on the 21st was the same task. If this is not correct, it will be easy to call a separate subroutine for each job.
2. I assumed that on each Sunday and on the 21st you wanted the job to fire at 10 PM.

Okay, here’s how I did it:
I first created two jobs that each trigger at 10 PM.
One is called each_Sunday and one is called each_21st.
I then set the frequency to daily (the -inc directive).
At this point both of those jobs will fire daily at 10 PM.
Finally I added a filter to filter for SUNDAY in the case of the each_Sunday job and the 21st day of the month in the each_21st job.

Here’s the code:

### Script: rgroetz.tg

## every_sunday at 10 PM
# Every Sunday at 10 PM, run my_job.
##
# Trigger set to daily at 10PM
# Use CRON matcher to filter for Sunday:
# -action -match -cron [-except] minute hour day_of_month month day_of_week
# Where: minute=don't care, hour=don't care, day_of_month=don't care,
# month=don't care, and day_of_week=1(SUN)
{
-name every_sunday
-start -time 10:00 PM -constrain 0 0 5 0
-action -onerror break
-action -match -cron * * * * 1
-action -call my_job
-action -inc 1 0 0 0
}

## each_21st at 10 PM
# Every 21st at 10 PM, run my_job.
##
# Trigger set to daily at 10PM
# Use CRON matcher to filter for the 21st day of the month:
# -action -match -cron [-except] minute hour day_of_month month day_of_week
# Where: minute=don't care, hour=don't care, day_of_month=21(the 21st),
# month=don't care, and day_of_week=don't care
{
-name each_21st
-start -time 10:00 PM -constrain 0 0 5 0
-action -onerror break
-action -match -cron * * 21 * *
-action -call my_job
-action -inc 1 0 0 0
}

## my_job
# It is assumed that the actions you want to carry out are shared bu both above jobs.
# Plug-in your actions here
{
-name my_job
-action -print "Matched each 21st OR every Sunday at " %X%
-action -print "** do stuff here **"
}
_________________________
Regards,
Luke Tomasello

Top


Moderator:  Luke Tomasello