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
тАО03-05-2004 02:03 AM
тАО03-05-2004 02:03 AM
only on the first weekend of the month with
saturday and sunday being in that month, not
split. And starting on saturday. Don't think
it can be done with cron.
The following crontab entry runs on the 1st
thru the 7th and "also" on saturday not "if"
it is saturday within the 1st - 7th day of the
month.
0 0 1-7 * 6
Solved! Go to Solution.
- Tags:
- crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2004 02:24 AM
тАО03-05-2004 02:24 AM
SolutionYou need to set the job to run on the saturday, then have logic within the script to test if the day is in the first seven days of the month
eg:
DATE_DAY=`date +%d`
if [ $DATE_DAY -le 7 ]
then
......
......
fi
This checks if the current day is less than or equal to 7, and runs the code in the if statement.
- Tags:
- date arithmetic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2004 02:26 AM
тАО03-05-2004 02:26 AM
Re: cron
Do you see what I mean?
-Hazem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2004 02:29 AM
тАО03-05-2004 02:29 AM
Re: cron
A. Clay Stephenson has some great utilities that help you figure that out. caljd.sh is on http://www.hpux.ws/merijn
I'm attaching a slightly out of date copy.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2004 02:33 AM
тАО03-05-2004 02:33 AM
Re: cron
unfortunately the crontab positions are not all connected with and but or.
Use as Chris suggests.
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2004 02:38 AM
тАО03-05-2004 02:38 AM
Re: cron
It cannot be done by default with cron. However, you can add that logic into your script to see if this day is first saturday and exit if not. Attached is a script that is to be prefixed to your orignal script. This checks if today is the day you specified via arguments. For ex.,
$./croncheck.sh 1 2
Usage ./ck.cron: Week Weekday
Example: ./ck.cron 1 Fri - for first friday
Your schedule is error
$./croncheck 1 sat
Your schedule is notok
$./croncheck 1 fri
Your schedule is ok
Edit the script and put exit instead of echoing MYSCHEDULE>
Run the whole script (this script + your script) on every saturday with the arguments 'croncheck 1 sat'. It will exit on all other saturdays except first saturday.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2004 02:48 AM
тАО03-05-2004 02:48 AM
Re: cron
Actually, you probably want this to run at 00:00 SUNDAY rather than Saturday if I understand your question.
I would change your crontab entry to:
0 0 * * 0
and then add this to your cronjob script. Make sure that PATH is set and exported because cron's environment is intentionally sparse.
I think I understand your question. You require that BOTH Saturday and Sunday be the first instance in this month. If Sunday is the 1st Sunday of the current month but Saturday is the last Saturday of the prior month, you do not want to trigger any action.
Caljd.sh -N's output indicates the occurrance of a current weekday withing the month (1 = 1st; 2 = 2nd; ...)
This should be added in your cronjob script:
if [[ $(caljd.sh -N) -eq 1 && $(caljd.sh -N -p 1) -eq 1 ]]
then
echo "Do your thing"
else
echo "Exit; do nothing"
fi
We are checking the occurance of today's weekday (-N) and also the occurance of the previous day (-N -p 1). Only if both equal 1 do we proceed.
Invoke as caljd.sh -u for full usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2004 02:56 AM
тАО03-05-2004 02:56 AM
Re: cron
why would you want to run the script on sunday? Remember the Vulcan High Councel does not believe in time travel! ;-)
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2004 03:14 AM
тАО03-05-2004 03:14 AM
Re: cron
Thanks all.