- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Cron to run every other Sunday
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
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
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-24-2003 10:02 AM
тАО04-24-2003 10:02 AM
Cron to run every other Sunday
Does anyone know how to code a cron to run every other Sunday at midnight?
Thanks...Susan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2003 10:09 AM
тАО04-24-2003 10:09 AM
Re: Cron to run every other Sunday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2003 10:09 AM
тАО04-24-2003 10:09 AM
Re: Cron to run every other Sunday
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xce7187dc4d7dd5118ff00090279cd0f9,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2003 10:47 AM
тАО04-24-2003 10:47 AM
Re: Cron to run every other Sunday
This may be one of those situations where at is a better alternative than cron.
Investigate setting this job up as an at job set to start the next Sunday you want it to run. Then as the last task of the at job have it run another at scheduled 14 days later.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2003 11:15 AM
тАО04-24-2003 11:15 AM
Re: Cron to run every other Sunday
a simple way is to first schedule the job to run every Sunday in crontab, e.g.:
10 15 * * 0 /usr/local/bin/sunday.sh
Then let the script decide which Sundays it should run. Use the "return day number command" for figuring that out, e.g.:
# date +%j
114
as there are 7 days in a week, every other Sunday would all be either odd day numbers or even day numbers.
Then let the script exit on either an odd or an even day number. Example:
#!/usr/bin/sh
#
# Check the day number of the year
#
typeset -i DAY_NUM=$( date +%j )
HALF=$(( $DAY_NUM \/ 2 ))
DOUBLE=$(( $HALF \* 2 ))
if [ "$DAY_NUM" != "$DOUBLE" ]
then
echo odd day
#exit
else
echo even day
# exit
fi
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2003 11:22 AM
тАО04-24-2003 11:22 AM
Re: Cron to run every other Sunday
Call the script every Sunday but ignore the odd Sundays.
Store the integer in a file.
Here's an 'untested' outline.
0 0 * * 1 /home/bill/scripts/sunday_script
#!/usr/bin/ksh
day=$(cat /home/bill/integer_file)
remainder=even_days%2
if [ $remainser=0 ]
then
execute script
if
even_days=$(($even_day+1))
echo $even_days>/home/bill/integer_file
(* Fool around with it. *)