![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Crontab Entry | Dastard | Shell Programming and Scripting | 5 | 02-09-2007 10:22 PM |
| crontab entry | Sowser | UNIX for Advanced & Expert Users | 4 | 01-08-2007 01:34 PM |
| Crontab entry | bestbuyernc | Shell Programming and Scripting | 1 | 09-12-2005 12:13 PM |
| crontab entry | matrixmadhan | UNIX for Dummies Questions & Answers | 3 | 06-07-2005 05:57 AM |
| Crontab First Monday of Month only | molonede | UNIX for Dummies Questions & Answers | 3 | 10-09-2001 06:38 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
crontab entry to run every last day of the month
i've created a script which should run every last day of the month. what would be the exact crontab entry for this? thanks!
|
| Forum Sponsor | ||
|
|
|
|||
|
Have cron run a script on days 28, 29, 30 and 31 of every month.
Create two variables in the script, one containing today's day of the month and another containing tomorrow's day of the month: TODAY=`date +%d` TOMORROW=`date +%d -d "1 day"` # See if tomorrow's day is less than today's if [ $TOMORROW -lt $TODAY ]; then echo "This is the last day of the month" # Do stuff... fi |
|
|||
|
My simple solution...
Was to turn the date math trick shown above into a script that I named 'last-day-of-month.sh':
Code:
#!/bin/bash
TODAY=`/bin/date +%d`
TOMORROW=`/bin/date +%d -d "1 day"`
# See if tomorrow's day is less than today's
if [ $TOMORROW -lt $TODAY ]; then
exit 0
fi
exit 1
Code:
12 0 * * * last-day-of-month.sh && /run/my/cron/job.sh -jason |
|||
| Google UNIX.COM |