1753336 Members
4694 Online
108792 Solutions
New Discussion юеВ

Re: Crontab

 
ramkumar
Valued Contributor

Crontab

Hi

is there anyway to run a process one day before the last date of every month using crontab. if so please guide me .
3 REPLIES 3
Robert-Jan Goossens
Honored Contributor

Re: Crontab

Hi,

Found this answer from Craig Rants in

http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x026250011d20d6118ff40090279cd0f9%2C00.html&admit=716493758+1105954821099+28353475

---
There is not much to it, but it always solves the problem of running a script on the last day of the month. Put 28-31 (for days) in your crontab and put this little section in for date determination.

#!/bin/sh

if test `TZ=MET-24 date +%d` = 01
then
exec command
else
exit 1
fi

---

Hope this helps,
Robert-Jan
Peter Godron
Honored Contributor

Re: Crontab

Hi,
a potentially easier, but not 100% accurate way would be to create 3 entries along the lines:
01 0 30 Jan,Mar,May,Jul,Aug,Oct,Dec * ./command.sh
01 0 29 Apr,Jun,Sep,Nov * ./command.sh
01 0 27 Feb * ./command.sh
This will not allow for leap years.


Peter Godron
Honored Contributor

Re: Crontab

ramkumar,
which solution did you go for in the end. Is this still a pronblem? If not can you please assign points and close the thread.
Thanks