- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Plannig cron job
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
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
тАО11-10-2005 02:52 PM
тАО11-10-2005 02:52 PM
I'm wondering how to plan cron job that runs every forth monday at 4.00 of every month?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2005 03:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2005 03:37 PM
тАО11-10-2005 03:37 PM
Re: Plannig cron job
1) Download the attached script, caljd.sh and install it in /usr/local/bin. Set the mode of this file to 755; chmod 755 /usr/local/bin/caljd.sh
2) Create a wrapper script that calls this utility. e.g. /usr/local/bin/mycrontask.sh
---------------------------
#!/usr/bin/sh
PATH=${PATH}:/usr/bin:/usr/local/bin
export PATH
STAT=0
if [[ $(caljd.sh -N) -eq 4 ]]
then
echo "Do your stuff here; it's the 4th Monday"
# remember to set ${STAT} to a non-zero value on failure
fi
# otherwise simply exit
exit ${STAT}
--------------------------------------
3) crontab -l > mycrontab
edit mycrontab and add this line
0 4 * * 1 /usr/local/bin/mycrontask.sh
save the file and
crontab < mycrontab
Here's the caljd.sh attachment. Invoke it as caljd.sh -u for full usage and many examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2005 03:39 PM
тАО11-10-2005 03:39 PM
Re: Plannig cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2005 07:49 PM
тАО11-10-2005 07:49 PM
Re: Plannig cron job
Work around is,
i) Use crontab setting as:
0 4 * * 1 <script to be executed as /test.sh> 1>/dev/null 2>&1
==> Execute at 4:00 on monday (1). It will execute on all weeks.
ii) To control to execute on month's forth monday then,
<script to be executed as /test.sh>
#!/bin/sh
if [[ $(date +'%d') = $(cal | grep -v '[a-z]' | cut -b 4-5 | grep -Ev ' |^$' | head -4 | tail -1) ]]
then
fi
# END
exit 0
PS:
You got a solution from olympian. This is with system default utility using cal instead of external script.
hth.