HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to schedule a job every other day?
Operating System - HP-UX
1837967
Members
2833
Online
110124
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
06-02-2003 02:21 PM
06-02-2003 02:21 PM
Hi Experts,
This should be a very simple task. I need to schedule a file transfer every other day at 5:00 AM. I can't find a combination of cron options that work. Any ideas?
Thanks,
David
This should be a very simple task. I need to schedule a file transfer every other day at 5:00 AM. I can't find a combination of cron options that work. Any ideas?
Thanks,
David
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 02:32 PM
06-02-2003 02:32 PM
Solution
The solution is rather straightforward. You need to simply run your script every weekday at 0500 from cron. The script itself will then determine if it needs to do the transfer or simply exit.
One naive approach would be
if [[ $(($(date) '+%j' % 2)) -eq 0 ]]
then
exit 0
fi
BUT don't do it because I've been told that some years have 365 days and others have 366 - your calculations will go awry.
Approach 2) Use an at command within your script to reschedule in 48 hours but don't do that neither. A chain is only as strong as its weakest link If the command ever fails before the at is issued, all subsequent commands fail.
Approach 3) Works everytime.
if [[ $(($(caljd.sh) % 2)) -eq 0 ]]
then
exit 0
fi
You may need to change the -eq 0 to -eq 1 but you get the idea. Search the Forums for a copy of caljd.sh. Version 2.1 is the latest. Caljd.sh -u will give full usage.
One naive approach would be
if [[ $(($(date) '+%j' % 2)) -eq 0 ]]
then
exit 0
fi
BUT don't do it because I've been told that some years have 365 days and others have 366 - your calculations will go awry.
Approach 2) Use an at command within your script to reschedule in 48 hours but don't do that neither. A chain is only as strong as its weakest link If the command ever fails before the at is issued, all subsequent commands fail.
Approach 3) Works everytime.
if [[ $(($(caljd.sh) % 2)) -eq 0 ]]
then
exit 0
fi
You may need to change the -eq 0 to -eq 1 but you get the idea. Search the Forums for a copy of caljd.sh. Version 2.1 is the latest. Caljd.sh -u will give full usage.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 02:35 PM
06-02-2003 02:35 PM
Re: How to schedule a job every other day?
Hi David:
Approach 4) Works everytime as well:
if [[ $(perl -e 'use integer; print ((scalar time / 86400) % 2),"\n"') -eq 0 ]]
then
exit 0
fi
This simply divides epoch seconds by 86400 (number of seconds per day) to get days and then does a mod 2.
Approach 4) Works everytime as well:
if [[ $(perl -e 'use integer; print ((scalar time / 86400) % 2),"\n"') -eq 0 ]]
then
exit 0
fi
This simply divides epoch seconds by 86400 (number of seconds per day) to get days and then does a mod 2.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 02:50 PM
06-02-2003 02:50 PM
Re: How to schedule a job every other day?
approach 5) you could write your own C program to get the number of seconds from the epoch using the ctime function. But, your system probably has perl already, and not an ansi C compiler.
approach 6) use a temp file to remember what was done yesterday, ie. day 1, temp file doesn't exist so create it, day 2, temp file exists so send file and remove temp file. But, it does have problems if the script is run multiple times on one day or if a day is missed.
approach 6) use a temp file to remember what was done yesterday, ie. day 1, temp file doesn't exist so create it, day 2, temp file exists so send file and remove temp file. But, it does have problems if the script is run multiple times on one day or if a day is missed.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP