- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to get cronjobs to skip holidays?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 08:32 AM
04-17-2003 08:32 AM
I have a number of cronjobs that run every weekday that I don't want to run on holidays like Good Friday. Is there a file that cron can read to skip holidays? I've looked at the man pages and found nothing.
Thanks,
Derek
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 08:36 AM
04-17-2003 08:36 AM
SolutionThat question came up yesterday and the answer is still the same - no, not directly. You should continue to run your cronjob daily BUT it should determine if today is a holiday.
1) Edit and update /etc/acct/holidays. I actually prefer that you create a file /etc/acct/holidays_YYYY and link /etc/acct/holidays to it for the current year.
2) Add something like this to your cron'ed script:
if [[ $(caljd.sh -h) -ne $(caljd.sh) ]]
then
echo "Today is a holiday"
exit 0
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 08:37 AM
04-17-2003 08:37 AM
Re: How to get cronjobs to skip holidays?
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x6e219607df6ed711abdc0090277a778c,00.html
Thanks
Zafar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 08:38 AM
04-17-2003 08:38 AM
Re: How to get cronjobs to skip holidays?
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x6e219607df6ed711abdc0090277a778c,00.html
You could probably have used the search function and searched on "cron and holiday" and probably would have gotten some hits.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 08:39 AM
04-17-2003 08:39 AM
Re: How to get cronjobs to skip holidays?
There is a file called /usr/lib/X11/datebook/holidays (hopefully it's on your system) that could be used, with a fairly substantial amount of effort, by a cron script to determine if a give day was a holiday. Then the cron script could proceed or exit depending on the comparison.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 08:45 AM
04-17-2003 08:45 AM
Re: How to get cronjobs to skip holidays?
"Thanksgiving"
=holiday
4th Thursday in November at 12:00 AM
and the other "floating" holidays.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 08:50 AM
04-17-2003 08:50 AM
Re: How to get cronjobs to skip holidays?
Thanks for the amazing quick solutions. It looks like Clay's is the one to beat. Clay, I have one question. You said that you wanted me to create a holidays_YYYY file and link it to holidays. Why?
Thanks,
Derek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 08:55 AM
04-17-2003 08:55 AM
Re: How to get cronjobs to skip holidays?
The answer is quite simple. Unlike the cheaper brands which purport to do Julian Days, caljd.sh actually does Julian Days and thus spans thousands of years - leap years and all without an if.
Consider the case of Dec 31, 2003 (New Year's Eve) AND Jan 1, 2004 (New Year's Day) both being holidays. The vanilla UNIX /etc/acct/holidays file was never meant to span years. Caljd.sh first looks to see if there is a holidays_YYYY file for whatever current year its calculation fall in and then look at the plain holidays file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 10:27 AM
04-17-2003 10:27 AM
Re: How to get cronjobs to skip holidays?
Thanks again,
Derek