- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to make cron 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
Discussions
Discussions
Discussions
Forums
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
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-16-2003 12:06 PM
тАО04-16-2003 12:06 PM
I have some routine tasks that are run each weekday by cron. This Friday is a company holiday so nobody will be here to change tapes. Is there a way to make cron skip holidays?
TIA, Steve
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 12:10 PM
тАО04-16-2003 12:10 PM
Solutionif [[ ${caljd.sh -h) -ne $(caljd.sh) ]]
then
echo "Today is a holiday."
exit 0
fi
You will need to create/update a seldom used anymore file called /etc/acct/holidays.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 12:12 PM
тАО04-16-2003 12:12 PM
Re: How to make cron skip holidays
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 12:21 PM
тАО04-16-2003 12:21 PM
Re: How to make cron skip holidays
You can invoke caljd.sh with -u for full usage. The -h checks for holidays and if true advances the Julian Day by one unless the next day also happens to be a holiday in which case the current Julian Day is incremented again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 12:21 PM
тАО04-16-2003 12:21 PM
Re: How to make cron skip holidays
http://forums.itrc.hp.com/cm/QuestionAnswer/0,,0xddda91ccb36bd611abdb0090277a778c,00.html
Thanks
Zafar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 12:21 PM
тАО04-16-2003 12:21 PM
Re: How to make cron skip holidays
You won't be able to do that from cron. You will have to modify your script to do it.
Regards,
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 12:37 PM
тАО04-16-2003 12:37 PM
Re: How to make cron skip holidays
then put this inside your side.
check_date()
{
#
# check if it is the alternative thursday?
#
if [ $DATE = 9 ] || [ $DATE = 23 ] || [ $DATE = 37 ] || [ $DATE = 51 ] || [ $DATE = 65 ] || 50 [ $DATE = 79 ] || [ $DATE = 93 ] || [ $DATE = 107 ] || [ $DATE = 121 ] || [ $DATE = 135 ] || 51 [ $DATE = 149 ] || [ $DATE = 163 ] || [ $DATE = 177 ] || [ $DATE = 191 ] || [ $DATE = 205 ] || 52 [ $DATE = 219 ] || [ $DATE = 233 ] || [ $DATE = 247 ] || [ $DATE = 261 ] || [ $DATE = 275 ] || 53 [ $DATE = 289 ] || [ $DATE = 303 ] || [ $DATE = 317 ] || [ $DATE = 331 ] || [ $DATE = 345 ] || [ $DATE = 359 ]
then
# send the email, else forget about it
EXECUTE anything you want done if it is the day you want the job to run
}
this code goes in your main (ksh)
BIN=/usr/local/bin
DT=`date +%D`
echo "$DT\nq\n" | $BIN/date2julian | awk '{print $9}' | read DATE
echo "$DT" | sed "s/\// /gp" | read M D Y
(( YESTERDAY = $DATE - 1 ))
echo "$YESTERDAY\nq\n" | $BIN/date2julian | awk '{print $7}' | read ETAD
echo "$ETAD" | sed "s/\// /gp" | read MM DD YY
check_date
put the attachment in your /usr/local/bin directory, make it executable.
enjoy
Donny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 12:42 PM
тАО04-16-2003 12:42 PM
Re: How to make cron skip holidays
also, i made a type in the previous posting.
the if statement in the function check_date() must have a fi in the line before the
check_date()
{
if [ $DATE = 5 ] || [ $DATE = 28 ]
then
do something
else
forget about it, and try again tomorrow, hahaha
fi
}
you can also omit the else and go strait to the
check_date()
{
if [ $DATE = 325 ]
then
echo "almost x-mas"
fi
}
peace
Donny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 12:49 PM
тАО04-16-2003 12:49 PM
Re: How to make cron skip holidays
the caljd.sh and it perl cousin is over 1090
line long. :o(
date2julian even knows and can calculate leap years. once you implement it. you can forget it forever, okay until the date runs over 3000.
I use it in every single script. nice to step back for backup jobs, when cron can't check if its month end.
date2julian you can go crazy, stepping back and forth in time, without skipping a day.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 12:52 PM
тАО04-16-2003 12:52 PM
Re: How to make cron skip holidays
I used your script inside my script and it works great if I run it from the shell but fails if I run it from cron. What's wrong?
TIA, Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 12:56 PM
тАО04-16-2003 12:56 PM
Re: How to make cron skip holidays
Your problem is very typical. Cron has an intentionally sparse environment. You need to do something like early in your cron'ed script:
PATH=${PATH}:/usr/local/bin
export PATH
assuming that you installed caljd.sh in /usr/local/bin. Plan B. use full paths when invoking caljd.sh (or anything else).
This should fix you - if you get /etc/acct/holidays set correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 01:18 PM
тАО04-16-2003 01:18 PM
Re: How to make cron skip holidays
Thanks, Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2003 01:32 PM
тАО04-16-2003 01:32 PM
Re: How to make cron skip holidays
I scheduled an special cron job kill the cron daemon. The system was idle so there was no need to have cron do anything for that holiday.
After the holiday I dialed right back in and restarted the deamon.
/sbin/init.d/cron start
Low tech, but for weekday holidays it worked fine.
My dba is complaining about Oracle backups kicked Passover, so I guess it's time to get Clay's script and implement it first test, then prod.
Good luck.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com