- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- System Administration
- >
- HP-UX Cron - run every first thursday of the month
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- Report Inappropriate Content
10-06-2015 04:18 AM
10-06-2015 04:18 AM
Hello,
I'm trying to cron something to run every first thursday on the month, but is not working properly.
I have:
0 10 1-7 * 4 /home/myscript > /dev/null 2>&1
so it should run at 10am, between day 1 and 7 of everymonth if weekday is 4 (thursday).
Instead it is runing everyday if 1-7....
Why not respecting the weekday?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-06-2015 06:16 AM
10-06-2015 06:16 AM
Re: HP-UX Cron - run every first thursday of the month
> Why not respecting the weekday?
If cron does day-of-month OR day-of-week (man cron), then it won't do
day-of-month AND day-of-week.
The usual solution for problems like this is to get cron to do the
best it can, and then add tests in the script to skip the unwanted
cases. For example, tell cron to run the script _every_ Thursday, and
have the script look for the _first_ Thursday. (Use "date", and look
for a day-of-month from 1-7.)
A Forum (or Web) search for keywords like, say:
cron day
should find many examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-06-2015 09:39 AM
10-06-2015 09:39 AM
Re: HP-UX Cron - run every first thursday of the month
Added in the top of the script:
chk_day=`date +%a`
if [ $chk_day = 'Thu' ];
then
my code
else
exit 0;
fi
Kept in the cron every 1-7 day in each month.
and it seems it is working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-06-2015 11:41 AM - edited 10-06-2015 11:42 AM
10-06-2015 11:41 AM - edited 10-06-2015 11:42 AM
Solution>Kept in the cron every 1-7 day in each month.
Yes, that makes the script easier.
>chk_day=`date +%a`
If you're worried about locales, you may want a day of the week in numeric format:
chk_day=$(date +%u) # 1 - 7 Mon .. Sun
if [ $chk_day != 4 ]; then # Thu
exit # if not Thursday, exit
fi
I hope you have comments in both crontab and the script to indicate how they work together.
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP