- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Make a cron run on 1st non-weekend day of the mont...
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
11-09-2004 04:32 AM
11-09-2004 04:32 AM
I have tried this cron entry
0 5 1 * 1-5 /usr/local/bin/notify
but it doesn't work right.
I want this script to run on the first non-weekend day of each month. My command runs every Monday through Friday. Is there a way to do this in unix?
TIA.
John
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2004 04:39 AM
11-09-2004 04:39 AM
SolutionWhat you really need to do is drop the monthday requirement replacing your '1' with '*' and your command will the run every Mon thru Fri. We then have to put some smarts in the command itself to determine if it should run or simply exit.
Here's my cut at it:
#!/usr/bin/sh
if [[ $(caljd.sh -M) -ne $(caljd.sh -p 1 -x 0 -x 6 -M) ]]
then
echo "First working day of the month; do your thing."
else
echo "It aint; don't do nothing; exit."
fi
You'll need the attached script to complete your task and make sure that you set and export PATH to include caljd.sh's location.
Invoke as caljd.sh -u for usage and examples and to see why this works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2004 04:45 AM
11-09-2004 04:45 AM
Re: Make a cron run on 1st non-weekend day of the month
I would do the cron entry like:
0 5 1-3 * * /usr/local/bin/notify
I would then modify the script so that it check if the day of week a Sat or Sun or not.
DOW=$(date +%a)
if [ ${DOW} = "Sat" -o ${DOW} = "Sun" ] ; then
exit 1
else
do your stuff here
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2004 04:50 AM
11-09-2004 04:50 AM
Re: Make a cron run on 1st non-weekend day of the month
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=734757
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2004 05:01 AM
11-09-2004 05:01 AM
Re: Make a cron run on 1st non-weekend day of the month
e.g. Christmas 2004
OFFSET=$(( $(caljd.sh 12 25 2004) - $(caljd.sh 12 31 2003) ))
echo "Offset = ${OFFSET}"
This suggests a simple script for these calculations but I'll leave that as a student exercise (or maybe I just don't know how).
No points for this, please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2004 07:51 AM
11-09-2004 07:51 AM
Re: Make a cron run on 1st non-weekend day of the month
Thanks again guys for all your help.
Regards,
John