Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron Date Problem

Status
Not open for further replies.

rbri

Programmer
Jun 27, 2002
84
0
0
US
Hello Everyone

I wrote a script to roll flexlm report logs once a month. I would like to include the month and year in the file name of the rolled report logs. This is where I am have my trouble I would like to roll them on the last day of the month but, I can't figure out how or even if cron will do the last day of the month since the day can be different month to month. I was told by a person here that the unix date command has the ability through format options to tell you the previous month but, I can't find any information on that and the person who told me doesn't remember how to do it. I am trying to keep the script simple but, maybe I can't. Any help that can be provided will be greatly appreciated
 
Hi,
insead of playing with "cron" try "at". Each execution might also schedule next one just one month later (you set first one by hand, and that's all)...

at 10:00 `date +'%x'` +1 months <<EOF
script
EOF

hope it helps,
Milosz
 
Another solution might be to write the date to a file every day (at 23:59, say) and then run your job at midnight on the first of each month (assuming a few seconds won't matter), appending the date from the file written at 23:59.
 
Hello

Thanks for the help I'll try both ideas but, for the requirements I received I think I going for the creating a file with the date in it. Again thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top