- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Monthly cronjobs
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-07-2010 09:07 AM
тАО03-07-2010 09:07 AM
Field descriptions of a crontab file say, 3rd field (Range 1-31). But, if I have to schedule a job to run every month end for a year starting Jan, how do i do that.
Pls suggest
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2010 09:33 AM
тАО03-07-2010 09:33 AM
SolutionThe definition of "month end" might differ from the actual last day of a month. If is doesn't and its the actual last day that you want to run on, let your script determine if it should exit or continue.
One way for your script to decide if its execution is on the last day of any month is something like this, exiting if it isn't time:
...
MONEND=$(cal $(date "+%m %Y")|awk '/[1-3]/ {DAY=$NF};END{print DAY}')
[ $(date "+%d") -ne ${MONEND} ] && exit
...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2010 02:53 PM
тАО03-07-2010 02:53 PM
Re: Monthly cronjobs
While it should be obvious from my initial remarks, given that it's the last day of any month that your script should run, I'd 'cron' it for the appropriate time something like this:
0 1 28,29,30,31 * * /path_toscript
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2010 07:05 PM
тАО03-07-2010 07:05 PM
Re: Monthly cronjobs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2010 09:17 PM
тАО03-07-2010 09:17 PM
Re: Monthly cronjobs
Thanks for these great ways of doing things.
Hi Dennis,
We tried to convince the mgmt, our job could be easier, but they'r strict about having the getting the reports on the last day of every month.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2010 05:31 AM
тАО03-08-2010 05:31 AM
Re: Monthly cronjobs
0 0 1 * * script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2010 06:55 AM
тАО03-08-2010 06:55 AM
Re: Monthly cronjobs
# echo `cal` | awk '{print $NF}'
this is today:
# date +'%d'
to evaluate if today is the last day of the month:
# [[ $(date +'%d') -eq $(echo `cal` | awk '{print $NF}') ]]
you can concatenate this to your cronjob and run it every day:
00 23 * * * [[ $(date +'%d') -eq $(echo `cal` | awk '{print $NF}') ]] && /root/GEN_REPORT.sh
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2010 07:00 AM
тАО03-08-2010 07:00 AM
Re: Monthly cronjobs
# [[ $(cal) = *$(date +%d) ]]
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1158441
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2010 12:32 PM
тАО03-08-2010 12:32 PM
Re: Monthly cronjobs
Didn't I already suggest that? :-)