- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- cron - running job on second Tuesday
Operating System - HP-UX
1821247
Members
3017
Online
109632
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
Discussions
Discussions
Discussions
Forums
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
тАО01-25-2005 06:28 AM
тАО01-25-2005 06:28 AM
cron - running job on second Tuesday
I need to run few jobs on 2nd Tuesday of the month and few on 4th Tuesday
How do i do this in cron?
Thanks
How do i do this in cron?
Thanks
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2005 06:33 AM
тАО01-25-2005 06:33 AM
Re: cron - running job on second Tuesday
Set the cron job to run on Tuesday and have the script check to see if the day of the month falls between 7 and 14 or set cron to run the job between 7 and 14 and have the script check to see if the day is Tuesday.
Pete
Pete
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2005 06:35 AM
тАО01-25-2005 06:35 AM
Re: cron - running job on second Tuesday
You don't directly. Cron is not smart enough itself to figure that out.
You will have to build some intelligence into your scripts to figure that out.
The 2nd Tuesday of the month could be anywhere from the 8th to the 14th. So what you should do is run the script every Tuesday and if the date is somewhere between the 8th and 14th of the month, then allow the script to run, otherwise exit.
Use the same logic for the 4th Tuesday, which could be anwhere from the 22nd to the 28th of the month.
You will have to build some intelligence into your scripts to figure that out.
The 2nd Tuesday of the month could be anywhere from the 8th to the 14th. So what you should do is run the script every Tuesday and if the date is somewhere between the 8th and 14th of the month, then allow the script to run, otherwise exit.
Use the same logic for the 4th Tuesday, which could be anwhere from the 22nd to the 28th of the month.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2005 06:37 AM
тАО01-25-2005 06:37 AM
Re: cron - running job on second Tuesday
Cron by itself can't do this. You need to make a crontab entry to spawn the job every Tuesday and then let the job itself determine if this is the 2nd (or 4th) Tuesday. Let's see, this is a date problem. I wonder what I'll use?
Your croned script should look something like this:
if [[ $(caljd.sh -N) -eq 2 ]]
then
echo "2nd Tuesday; do your thing"
else
# it ain't; do nothing
exit 0
fi
Invoke the attached caljd.sh script as caljd.sh -u for full usage and examples.
Your croned script should look something like this:
if [[ $(caljd.sh -N) -eq 2 ]]
then
echo "2nd Tuesday; do your thing"
else
# it ain't; do nothing
exit 0
fi
Invoke the attached caljd.sh script as caljd.sh -u for full usage and examples.
If it ain't broke, I can fix that.
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
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP