- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to schedule a cron job to run on the third thu...
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
тАО09-16-2002 07:52 AM
тАО09-16-2002 07:52 AM
I'm hoping someone can help me write this properly. I have a job I need to run on the 3rd thursday of the month, every month. I've tried the following line in my crontab but it doesn't work properly:
1 1 15,16,17,18,19,20,21 * 5 /optim/bin/testcron.scr #
Thanks so much!!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:03 AM
тАО09-16-2002 08:03 AM
Re: how to schedule a cron job to run on the third thursday of the month.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:04 AM
тАО09-16-2002 08:04 AM
Re: how to schedule a cron job to run on the third thursday of the month.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:04 AM
тАО09-16-2002 08:04 AM
Re: how to schedule a cron job to run on the third thursday of the month.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:10 AM
тАО09-16-2002 08:10 AM
Solution1 1 ..... * 5 /optim/bin/cron_date_check #
Add these lines in the script:
if [ `date |awk '{print$1}'` = "Thu" ]
then
/optim/bin/testcron.scr
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:11 AM
тАО09-16-2002 08:11 AM
Re: how to schedule a cron job to run on the third thursday of the month.
Change the 5 (or 4) to a *
Then it should just run on the specified dates.
You can then build logic into your script to test if date +%a is equal to Thu, and only continue if it is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:13 AM
тАО09-16-2002 08:13 AM
Re: how to schedule a cron job to run on the third thursday of the month.
Note that the specification of days can be made in two fields: monthday and weekday.
If both are specified in an entry, they are cumulative. For example,
0 0 1,15 * 1 command
runs command at midnight on the first and fifteenth of each month, as well as every Monday.
Which explains why is is always running on those days.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:16 AM
тАО09-16-2002 08:16 AM
Re: how to schedule a cron job to run on the third thursday of the month.
I think
1 1 15,16,17,18,19,20,21 * 4 /optim/bin/testcron.scr , should work fine
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:17 AM
тАО09-16-2002 08:17 AM
Re: how to schedule a cron job to run on the third thursday of the month.
The correct solution is to run your command every Thursday (weekday 4) and then inside the script do a 2nd test.
e.g.
MDAY=$(date '+%m')
if [[ $(MDAY} -ge 15 && ${MDAY} -le 21 ]]
then
echo "Run your commands; it's the 3rd Thursday"
else
echo "Exit; not the 3rd Thursday"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:18 AM
тАО09-16-2002 08:18 AM
Re: how to schedule a cron job to run on the third thursday of the month.
I fear that cron' syntax is not able to handle it (maybe I'm missing something).
But you could use a workaound... schedule the job for EACH Thursday and check if it's the 3rd one, e.g.:
1 1 * * 5 (( ($(date "+%e")-1) / 7 +1 == 3 )) && echo This is the job!
Only a rapid prototype... hope it works. :-)
Regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:20 AM
тАО09-16-2002 08:20 AM
Re: how to schedule a cron job to run on the third thursday of the month.
1 1 * * 5 (( ($(date "+%e")-1) / 7 +1 == 3 )) && echo This is the job!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2002 08:21 AM
тАО09-16-2002 08:21 AM
Re: how to schedule a cron job to run on the third thursday of the month.
1 1 * * 4 (( ($(date "+%e")-1) / 7 +1 == 3 )) && echo This is the job!