- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Doubt in crontab
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
04-23-2007 01:20 PM
04-23-2007 01:20 PM
Doubt in crontab
i want to schedule the cron job in crontab on 2nd sunday of every month.
Is it possible?if so how to do it..
help apperciated .
- Tags:
- crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2007 01:27 PM
04-23-2007 01:27 PM
Re: Doubt in crontab
------------------------------------------
#!/usr/bin/sh
typeset -i STAT=0
export PATH=${PATH}:/usr/local/bin
if [[ $(caljd.sh -N) -eq 2 ]]
then
echo "2nd Sunday; do your thing."
STAT=${?}
fi
exit ${STAT}
--------------------------------------------
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
04-23-2007 05:46 PM - edited 09-18-2011 03:14 PM
04-23-2007 05:46 PM - edited 09-18-2011 03:14 PM
Re: Question on crontab
>Clay: you can run a script every Sunday and then let the script decide if it is the 2nd Sunday
You might want to reverse that and run it for every second week and then have the script test for Sunday. (Even though it fires off 7 days a month instead of 4 or 5, the scripting is easier.)
# The test for Sun is in the script.
00 05 08-14 * * gen_monthly_status
WD=$(date +"%a")
if [ $WD != "Sun" ]; then
exit
fi
If you are worried about locales, you may want to use "%u" and check for 7.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2007 05:47 PM
04-23-2007 05:47 PM
Re: Doubt in crontab
By using cron it is possible to schedule jobs
on all Sundays/Weekdays, for schjeduling on Sundays
If u want to schedule a job on every 2nd Sunday,
u schedule the job to run on all sundays and
check in the job itself if it is 2nd sunday or not.
eg.
ur cronfile may look like this.
--------------------------
0 0 20 * * 0 /
--------------------------
Add code to check occurance of Sunday in job.sh
job.sh
----------
#! /usr/bin/ksh
Day=`date +'%d'`
Week=`echo "scale=0;($Day + 6) / 7"|bc -l`
if [ $Week -eq 2 ]
then