1847183 Members
3776 Online
110263 Solutions
New Discussion

preserve cron log

 
SOLVED
Go to solution
John Kittel
Trusted Contributor

preserve cron log

Some auditors want us to keep / check completion status of all cron jobs in a single log.

I can use /var/adm/cron/log for this, except that it gets recreated every time cron is restarted, and the old log copied to OLDlog. What approach would be best to solve this problem?

I'm considering modifying the cron startup script not to start a new log every time and then invent another method of trimming the log at more desireable intervals, for example once every 6 months remove the first month's entries, or something like that.

Or would it be better to come up with a way of duplicating in real time all entries in the cron log to another log?

Or some other scheme?

- John
4 REPLIES 4
Pete Randall
Outstanding Contributor
Solution

Re: preserve cron log

John,

The cron log is moved to OLDlog by the /sbin/init.d/cron startup script. You could modify it to your needs but would need to be careful that the startup script did not get overlaid during the application of patches, etc.


Pete

Pete
Shahul
Esteemed Contributor

Re: preserve cron log

Hi John,

I think it's not a good idea to keep all the logs for ages in a single file. It has to be regenerated in regular intervals.

you may need to feed the auditors back that, it's an OS inbuilt facility to duplicate and regenerate a new file in each time. Why should we stop this!!!

Most of the logs in various UNIX are managed like that.

Best of luck
Shahul
James A. Donovan
Honored Contributor

Re: preserve cron log

rotatelog is a popular choice....

http://www.interhack.net/projects/rotatelog/
Remember, wherever you go, there you are...
Senthil Kumar .A_1
Honored Contributor

Re: preserve cron log

Hi,

The cron daemon start in run level 2. In the cron start up script /sbin/init.d/cron , there is a line which moves the cron log to OLDlog as shown below...

'start')
if [ -f /etc/rc.config.d/cron ] ; then
. /etc/rc.config.d/cron
else
echo "ERROR: /etc/rc.config.d/cron defaults file MISSING"
fi

if [ "$CRON" -eq 1 -a -x /usr/sbin/cron ]; then
if [ -f /var/adm/cron/log ]; then
mv /var/adm/cron/log /var/adm/cron/OLDlog
fi
/usr/sbin/cron && echo cron started
set_return
else
rval=2
fi

;;

The elegant method would be to just, modify this line to suite you purpose. The realtime copy of cron log is unecessary,which simply consumes processor power for no advantage and adds one more process in the table.

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)