There's a script I would like to run daily every 5 minutes and this job should restart every 12:03AM so it would append to a new file with the following day date format instead of running and updating continuously into one log. I am not sure of the syntaxing, what I did was to set it to run daily 1-31..any idea on how to set it to run every 5 mins and refresh at 12:03 am?
##Run memory report every 5 mins daily
*/5 * 1-31 * * /usr/local/bin/MEM_Report/MEM_daily_run
Well, it doesn't have to be exactly 12:03 AM, its just that I want a new report with the following day's date format
I was thinking of
*/5 0-23 * * *
maybe I should wait out till tomorrow so I can see how the reports come out..I started the script just now..cron confuses me every time
hi hedkandi,
your script is seem OK.
but as already mentioned by @methly, system date settings and cron may use different timezone information(TZ).
check if your system (redhat derivative )
# cat /etc/crontab
or solaris
# grep ^TZ /etc/TIMEZONE
check your user's profile file that runs this cronjob
both of them are differ?
Just realised that your original cron from post #1 must have been running the script every 5 minutes and therefore appending to the output file every 5 minutes. So if you look at 11:00 local time the timestamp changes ... and again at 11:05 etc. . There is nothing obvious wrong with the timestamp on that file unless it wasn't 11:00 when you looked.
What are you trying to do and what is your expected output?
Im trying to get memory reading with the ps command every 5 minutes, 24 hours a day unless the system is down (its set up with S'pore time zone). Since the previous 2 cron settings didn't work, so I edited the cron to run 5 mins and all other paramaters set as * :
[root@EP-WCRM1 03]# ls -lrt
total 572
-rw-r--r--. 1 root root 206521 Mar 19 23:55 2012-03-19
-rw-r--r--. 1 root root 186589 Mar 20 12:15 2012-03-20
-rw-r--r--. 1 root root 82800 Mar 21 23:55 2012-03-21--------working!
-rw-r--r--. 1 root root 85050 Mar 22 15:40 2012-03-22
and this is how my cronjob looks like now:
##Run memory report every 5 mins daily
*/5 * * * * /usr/local/bin/MEM_Report/MEM_daily_run
Also, there's another script that creates an empty report file every day at 1min past midnight: