- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Make jobs not run on 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
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
07-02-2002 11:49 AM
07-02-2002 11:49 AM
July 4th and 5th are company holidays. We have some routine cron jobs that run Monday through Friday. I have updated the system holidays file but I can't find an option for cron to make it skip the holidays in the holidays file. I can change the cron entries this week but I would really like to have it automatically skip holidays. Is there a hidden cron option? I would think that think would be a very common situation.
Thank you,
Mary Rice
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2002 11:57 AM
07-02-2002 11:57 AM
SolutionThere is no undocumented or hidden (well, if it's hidden it's well hidden) cron option to ignore holidays as defined in /etc/acct/holidays. However, I think we can do this with the date sledgehammer, caljd.sh or caljd.pl. The newest is Version 2.1 but anything after 2.05? will work.
In your scripts add this after making sure that caljd.sh and awk are in your PATH.
if [[ $(caljd.sh) -eq $(caljd.sh -h) ]]
then
echo "Do your stuff"
else
echo "Today is a holiday; skip it"
fi
Basically, the -h will return the next Julian Day that is not a holiday; thus, if these values for today's date differ, today must be a holiday.
This should fix you, Clay
Here's the latest caljd.sh; invoke it as caljd.sh -u for full usage:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2002 11:57 AM
07-02-2002 11:57 AM
Re: Make jobs not run on holidays
Unfortunately, you will need to adjust the cron entry for this week.
Sorry,
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2002 11:58 AM
07-02-2002 11:58 AM
Re: Make jobs not run on holidays
You can use either caljd.sh or caljd.pl; the options are exactly the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2002 12:22 PM
07-02-2002 12:22 PM
Re: Make jobs not run on holidays
You need to have your applications/scripts skip the days using a holiday/nowork table. cron just trudges along doing what it is told.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2002 01:19 PM
07-02-2002 01:19 PM
Re: Make jobs not run on holidays
I went to a meeting and I had my answers as soon as I got back to my workstation. It looks like it's not quite as easy as I would have liked but I just added these lines to the beginning of my scripts.
if [ $(caljd.sh) -ne $(caljd.sh -h) ]
then
exit 0
fi
I wish there were a way to test it before the July 4th.
Thank you very much,
Mary Rice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2002 01:25 PM
07-02-2002 01:25 PM
Re: Make jobs not run on holidays
Your scripts should be fine as long as caljd.sh and awk are in your PATH. You might need to do a little exporting before these lines.
Actually you can test now:
1) Temporarily add today's date to your holidays file.
OR
2) Temporarily change $(caljd.sh [-h]) to $(caljd.sh [-h] MM DD YYYY) to test any day you like.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2002 01:29 PM
07-02-2002 01:29 PM
Re: Make jobs not run on holidays
Thanks, Clay. My PATH was already set and exported.
Mary Rice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2002 05:27 AM
07-03-2002 05:27 AM
Re: Make jobs not run on holidays
#!/bin/ksh
# make your own hack to remove leading 0's in variables!
HOLIDAY=0
DATE=`date +%d/%m`
LCOUNT=`cat /etc/acct/holidays|grep -v ^\* | wc -l`
LNEED=`expr $LCOUNT - 1`
for LINE in `tail -$LCOUNT /etc/acct/holidays|grep -v ^\*` ; do
TMP=`echo $LINE|awk '{print $1}'`
HD=`echo $TMP|awk -F/ '{print $1}'`
HM=`echo $TMP|awk -F/'{print $2}'`
if [ "${HD}/${HM}" = $DATE ] ;then
echo "holiday today"
else
echo "Bah, another workday"
HOLIDAY=0
fi
done
Then in yyour scrips just have them test for HOLIDAY=1 or 0 in order to run.
There are advances (well used to be anyway) schedulars you can purchase which enhance Cron's abilities like you want. Im too cheap though, so use methods similar to the above.
NOTE: I did not test the above except for grep syntax in ksh and csh (syntax fails in Solaris /bin/sh). Dont complain if it dont work, just giving an example.
Regards,
Shannon