Clearing log files automatically
You can clear log files automatically using
crontab(C)
and
cron(C).
By adding a line to root's crontab file
(/usr/spool/cron/crontabs/root),
you can make your own file maintenance scripts execute
daily, weekly, or monthly.
The following is one of the default entries in root's crontab file:
17 5 * * 0 /etc/cleanup > /dev/nullSee crontab(C) manual page for complete information on the format of the crontab file.
This entry runs /etc/cleanup each Sunday morning at 5:17.
The /etc/cleanup script looks like this:
:
#
# clean up super-user log
cp /usr/adm/sulog /usr/adm/Osulog
> /usr/adm/sulog
#
# clean up volcopy log
[ -f /etc/log/filesave.log ] && mv /etc/log/filesave.log /etc/log/Ofilesave.log
> /etc/log/filesave.log
chown root /etc/log/filesave.log
chgrp sys /etc/log/filesave.log
chmod 666 /etc/log/filesave.log
#
# clean up wtmp
> /etc/wtmp
#
# clean up miscellaneous files
find / -name core -atime +7 -exec rm -f {} \;
The /etc/cleanup script:
You can specify different files to clear and when to clear them by modifying /etc/cleanup and the /usr/spool/cron/crontabs/root file.