How to make crond run on the last day of February

S

Sergii

Guest
Here is my code
[ $(date +%d) -eq $(echo `cal` | cut -d" " -f $(echo `cal` | wc -w)) ] && here your command's code

but i think it could be done in more elegant way
 


today=2802
check='date+%d%m'
if ( $today = $check )
then
script.sh
else
echo "nothing to do"
fi
add this to your daily crontab.
 
Or perhaps:
Code:
[ `date -d tomorrow +%d%m` -eq '0103' ] && <your script>
If tomorrow is the 1st of March, then today must be the last day of February - so execute the script! :)
 
0 0 28,29,30,31 * * [ `date -d tomorrow +\%d` -eq '01' ] && $(`/usr/sbin/logrotate -f -s /home/oracle/.scripts/logs/allrotate.status /home/oracle/.scripts/logs/listener`)
 

Members online


Latest posts

Top