- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Cron Entry - Please Advice.
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
08-08-2005 07:25 PM
08-08-2005 07:25 PM
Cron Entry - Please Advice.
I do not want to run /home/saras/dudd script on every first day of the month and saturday. so the crontab entry looks like below.
30 1 2-31 * 0-5 /home/saras/dudd
I could skip on saturday facing problem with first day of the month. Though I gave 2-31 still its running on 1st day of the month.
Iam using HP UNIX 11.11
Please advice in this matter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2005 07:39 PM
08-08-2005 07:39 PM
Re: Cron Entry - Please Advice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2005 07:41 PM
08-08-2005 07:41 PM
Re: Cron Entry - Please Advice.
I think you must specify the corect day according to the month,so i think you must create 12 line job.For example at Year 2005:
jan :31 days
feb: 28 days
mar: 31 days
...
dec:31 days
so change your crontab file to:
0 1 2-31 1 0-5 /home/saras/dudd
0 1 2-28 2 0-5 /home/saras/dudd
....
0 1 2-31 12 0-5 /home/saras/dudd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2005 07:54 PM
08-08-2005 07:54 PM
Re: Cron Entry - Please Advice.
30 1 * * 0-5 /home/saras/dudd 1>/dev/null 2>&1
in /home/saras/dudd put in the begin like,
if [[ $(date +'%d') -eq 1 ]]
then
echo "No need to run"
exit 0
fi
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2005 08:08 PM
08-08-2005 08:08 PM
Re: Cron Entry - Please Advice.
if [ `date | awk '{print $3}' | bc` -ne 1 ]
then
.
.
.
.
.
fi
Then the cron entry would look like this:
30 1 * * 0-5 /home/saras/dudd
That is the way I would do it.
There is probably a way to do it just using cron too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2005 05:13 AM
08-09-2005 05:13 AM
Re: Cron Entry - Please Advice.
Though I give 0-5 days the script executed on saturday. which I do not want.
30 1 2-31 * 0-5 /home/saras/dudd
Mr. Ermin Borovac, Could you please elaborate on this
"Entries in the 3rd and 5th column in crontab are cumulative. So your cronjob will be run on 2-31 day of each month PLUS Sunday to Friday".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2005 05:42 AM
08-09-2005 05:42 AM
Re: Cron Entry - Please Advice.
Call a script that has the logic built into it.
set `date +'%d %w'`
DAY=$1
WEEKDAY=$2
if [ "$WEEKDAY" != "6" ]
then
/home/saras/dudd
else
echo "Not running script"
exit
fi
Basically saying that this script checks the WEEKDAY and if it is SAT (6) then do not run dudds and exit.
The cron entry looks like
30 1 2-31 * *
This cron entry will execute the script everyday of the year except the 1st day of a month. The logic in the script says not to run 'dudd' on Saturdays.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2005 08:04 AM
08-09-2005 08:04 AM
Re: Cron Entry - Please Advice.
that should should run your script 2-31 of every month but not on saturdays.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2005 06:46 PM
08-09-2005 06:46 PM
Re: Cron Entry - Please Advice.
Could you please tell how exactly the below statement is going to work. Just curious to know
[[ `date +\%u` -ne 6 ]] &&
Since the cron log shows :-
CMD: [[ `date +%u` -ne 2 ]] && date>/home/infra/dat
Does cron considers the above statement as single command ? Please clarify
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2005 06:50 PM
08-09-2005 06:50 PM
Re: Cron Entry - Please Advice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2005 01:25 AM
08-10-2005 01:25 AM
Re: Cron Entry - Please Advice.
executes the date command getting day of the week as 1 - 7 (sunday is 7) if that does not equal 2 then it runs the script. Thus it will be false on Tuedays and would not run the script. Since false is a non-zero return.
Cron runs entries in the Posix shell that is why the [[ ]] syntax works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2005 05:05 PM
08-11-2005 05:05 PM
Re: Cron Entry - Please Advice.
I just came up with one logic which is
[ `date +\%d` -ne 1 ]
Is this logic which Iam using is Korn shell specific.
Please Advice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2005 05:35 PM
08-11-2005 05:35 PM
Re: Cron Entry - Please Advice.
if [[ `date +$d` -ne 1 ]]
then
Only one expression;
fi
If you don't want to execute /home/saras/dudd script on first day of month simply do in the /home/saras/dudd script as,
[[ $(date +%d) -eq 1 ]] && exit 0;
in the begining of script.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2005 05:36 PM
08-11-2005 05:36 PM
Re: Cron Entry - Please Advice.
This can be done in two ways
1. In crontab include dates 2-31 and modify the script in such a way that it does not run on Saturday. or
2. In crontab include the days except sat and modify the script to check the date and does not execute on 1st day of month...
Enjoy!!!
eknath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2005 05:43 PM
08-11-2005 05:43 PM
Re: Cron Entry - Please Advice.
If you don't want to execute on first day of month and saturday of the week then,
30 1 * * * [[ $(date +%d) -ne 1 || $(date +%w) -ne 5 ]] && /home/saras/dudd 1>/dev/null 2>&1
hth.