Operating System - HP-UX
1753774 Members
7313 Online
108799 Solutions
New Discussion юеВ

cron with extended feature

 
SOLVED
Go to solution
Alexander Milovanov
Occasional Contributor

cron with extended feature

Hello,

In crontab I can set values for the day of the week: 0-6, for example
00 03 * * 3,6 csh -c '_command_'

I need to schedule some jobs on each fourth Friday. (Something like 00 03 * * 1-6/4 csh -c '_command_')
I think I cannot set such value in standard HP-UX cron, but maybe you know any tools to do that?

Thanks.
4 REPLIES 4
Pete Randall
Outstanding Contributor

Re: cron with extended feature

You need to put that logic in your script. You could test the day of the month to see if it is greater than 21, for example.


Pete

Pete
RAC_1
Honored Contributor

Re: cron with extended feature

You can not do that with cron. Search forums data hammer. This is tool developed by AC Clay for such things. Else, you need to put it for every froday and check if a friday is 4th, then execute your script.
There is no substitute to HARDWORK
Arturo Galbiati
Esteemed Contributor
Solution

Re: cron with extended feature

Hi,
you cannot do teh same using crontab only.
You have to write a wrapper script (sheduled to run every day in crontab or better every Friday) that checks about teh 4th Friday of teh month and if this is the case start your script.

#!/usr/bin/ksh
set -A Friday $(cal|awk 'NR>3 {print $6}'|grep -v ^$)
integer friday4=${Friday[3]}
integer today=$(echo $(date +%d)+0|bc)
if [[ $today = $friday4 ]]
then
echo "Today is the 4th friday of teh month"
#run your script here
fi

HTH,
Art
Alexander Milovanov
Occasional Contributor

Re: cron with extended feature

Thanks a lot