Operating System - HP-UX
1825759 Members
2223 Online
109687 Solutions
New Discussion

Better scheduler than cron?

 
SOLVED
Go to solution
Tim Medford
Valued Contributor

Better scheduler than cron?

I need to have a cron job run only on the last day of the month. Cron doesn't really support this unless you manually schedule 12 separate jobs per year.

Has anyone ever tried to do this? I would appreciate any suggestions.

Thanks,
Tim
9 REPLIES 9
Craig Rants
Honored Contributor
Solution

Re: Better scheduler than cron?

Tim,
Try the 28-31 days for cron and use this in the head of your script.

if test `TZ=MET-24 date +%d` = 01
then
"execute command"
else
"don't execute command"
fi

This should solve your problem.

Good Luck,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Sanjay_6
Honored Contributor

Re: Better scheduler than cron?

Hi Tim,

suggest you to live with the cron. It is a difficult proposition to schedule a cronjob on the last day of each month through cron, but you can get away with a few entries in place of 12. you need 3 entries, one for months with 31 days, one for month with 30 days and one for feb 28/29 days.

Hope this helps.

Regds
S.K. Chan
Honored Contributor

Re: Better scheduler than cron?

The company I used to work with uses Maestro for job scheduling.

http://www.tivoli.com/products/index/workload_sched/
Tim Medford
Valued Contributor

Re: Better scheduler than cron?

Thank you for the replies!

Craig, that is a great solution! It took me a few minutes to figure out what you are doing, but now I understand it.

Thanks again
Roger Baptiste
Honored Contributor

Re: Better scheduler than cron?

Tim,

For scheduling software, you can check Tidal software''s sysadmiral. We used it in an earlier site.
Another choice is BMC''s control-m

HTH
raj
Take it easy.
A. Clay Stephenson
Acclaimed Contributor

Re: Better scheduler than cron?

Hi Tim:

I would use my caljd.sh script to do this:

Your cron script should look somethinh like this:

#usr/bin/sh

export PATH=${PATH}:/usr/local/bin

if [ "$(caljd.sh $(caljd.sh) | awk '{print $1}')" != "$(caljd.sh -n 1) | awk '{print $1}')" ]
then
echo "Run It"
fi

You could simply make a cron entry to run every day and the above script will take care of it. It simply looks for when the $1 (month) output of today is different from that of the next day (-n 1). I would install caljd.sh in /usr/local/bin. If you want to see how this insane caljd.sh script works, just do a caljd.sh -u for full usage.

P.S. I hope I got all those pesky quotes above correct.

Regards, Clay


If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: Better scheduler than cron?

Hi Tim:

I'm an idiot. I missed a $(cvaljd.sh) call. It should look like this:

PATH=${PATH}:/usr/local/bin
export PATH
if [ "$(caljd.sh $(caljd.sh) | awk '{print $1}')" != "$(caljd.sh $(caljd.sh -n 1) | awk '{print $1}')" ]
then
echo "Month Changed"
else
echo "Month Same"
fi

The real advantage is that this method makes it very easy to run n days before the last day of the month (or only on weekdays and skip holidays with just a few more caljd.sh options)
If it ain't broke, I can fix that.
Jim Finkel
New Member

Re: Better scheduler than cron?

We just trialed UC4, great product, and easy to use. www.seasoft.com
Hai Nguyen_1
Honored Contributor

Re: Better scheduler than cron?

Tim,

This code should work as well.

if [ `cal | tail -2 | head -1 | awk '{ print $NF }'` -eq `date | awk '{ print $3 }' ]; then
execute the code
fi

Hai