LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cron last day of every month (https://www.linuxquestions.org/questions/linux-general-1/cron-last-day-of-every-month-153034/)

lobo78 03-03-2004 11:14 AM

cron last day of every month
 
How would you go about writing a crontab entry for a job that would run at 11:59pm on the last day of every month? It can't be static since the days in a month varies from 28 to 31.

Also, how can you deal with leap years?

wapcaplet 03-03-2004 11:42 AM

The crontab (5) manual page has some details on specifying hours, minutes, and days of the month (type 'man 5 crontab' to see it).

I also found this and this after some searching.

It'd probably be a lot easier to just run it on the 1st of the month at midnight :)

homey 03-03-2004 08:41 PM

Digging around on the web, this is as far as I get. I'm not entirely sure if this will handle the leap year. Would appreciate if you find out to let me know.

Code:

#All months with 31 days
59 23 31 1-7/2,8-12/2 * /mnt/backup/backup.job
# All months with 30 days
59 23 30 4,6,9,11 * /mnt/backup/backup.job
#February on a normal year
59 23 28 2 * /mnt/backup/backup.job
#February on a leap year (maybe)
59 23 29 2 5 /mnt/backup/backup.job



All times are GMT -5. The time now is 08:30 AM.