- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: crontab 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
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
11-13-2007 06:48 PM
11-13-2007 06:48 PM
crontab job
thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2007 07:51 PM
11-13-2007 07:51 PM
Re: crontab job
yes it seems correct.
And if 1st of the month will be on monday or tuesday then the script will run only once.
Short extract from cron manpage:
When a command is specified to run at an ambiguous time, the command is executed only once at the first occurrence of the ambiguous time.
Gabriel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2007 07:56 PM
11-13-2007 07:56 PM
Re: crontab job
00 07 1 * * my_script #1st of mont
00 07 * * 1,2 my_script #monday and tuesday
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2007 08:27 PM
11-13-2007 08:27 PM
Re: crontab job
This will do it twice.
Better to let it OR as Gabriel said.
(A comment may be helpful if you think the OR is tricky.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2007 08:42 PM
11-13-2007 08:42 PM
Re: crontab job
> " 00 07 1 * 1,2 my_script "
This mean run my_script only when "Day of month" = 1 AND "Day of week" is Monday or Tuesday.
Of course, not what you want.
>>Oviman
00 07 1 * * my_script #1st of month
00 07 * * 1,2 my_script #monday and tuesday
This will run twice if "Day of Month" is 1 and it is ALSO either monday or tuesday.
What you need:
==============
#*******************************************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------------------------------
#*******************************************************************************
00 07 1 * * my_script #1st of month
00 07 * * 1,2 [ ! $(date +%e)=1 ] && my_script #run if not 1st
#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2007 08:48 PM
11-13-2007 08:48 PM
Re: crontab job
Sorry missed the explanations.
00 07 1 * * my_script #1st of month
00 07 * * 1,2 [ ! $(date +%e)=1 ] && my_script #run if not 1st
The first line:
Run every 1st day of the Month
The Second line:
Run every monday and tuesday, except if either is the 1st day of the month -- taken care by the 1st line.
Hope this helps!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2007 08:50 PM
11-13-2007 08:50 PM
Re: crontab job
>This means run my_script only when "Day of month" = 1 AND "Day of week" is Monday or Tuesday.
That's NOT what the man page says. Only tztab does AND. crontab(1) says:
If both are specified in an entry, they are cumulative.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2007 09:04 PM
11-13-2007 09:04 PM
Re: crontab job
Thanks a lot for these clarifications. I really had missed that!
Below the quote from "man crontab":
===========================================
Note that the specification of days can be made in two fields: monthday and weekday.
If both are specified in an entry, they are cumulative. For example,
0 0 1,15 * 1 command
runs command at midnight on the first and fifteenth of each month, as well as every Monday.
===========================================
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2007 09:06 PM
11-13-2007 09:06 PM
Re: crontab job
this should work fine for you:
00 07 1 * 1,2 my_script
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2007 02:01 PM
11-14-2007 02:01 PM
Re: crontab job
so what I need to set ? my above setting is correct ? or I need to set as below ? thx.
00 07 1 * * my_script #1st of month
00 07 * * 1,2 [ ! $(date +%e)=1 ] && my_script #run if not 1st
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2007 02:11 PM
11-14-2007 02:11 PM
Re: crontab job
Put these line in crontab files.
#minute (0-59),
#| hour (0-23),
#| | day of the month (1-31),
#| | | month of the year (1-12),
#| | | | day of the week (0-6 with 0=Sunday).
#| | | | | commands
0 2 * * 0,4 /etc/cron.d/logchecker
Thanks to UGU :)
Kapil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2007 02:18 PM
11-14-2007 02:18 PM
Re: crontab job
Yes. I finally convinced Yogeeraj that his complex version wasn't needed.
See his:
to summarize: this should work fine for you:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2007 03:17 PM
11-14-2007 03:17 PM
Re: crontab job
I have one addition question , if I want run on 1st of month when if it is Mon or Tue , can advise how to set ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2007 04:26 PM
11-14-2007 04:26 PM
Re: crontab job
You want to run on first AND ONLY if it is Mon or Tue?
You reverse what Yogeeraj had. (And fiddle with it a little. :-)
00 07 * * 1,2 [ $(date +%d) -eq 1 ] && my_script #run if 1st
Note you can also put the date check in the script so you don't clutter up the crontab.