|
|
You can clear log files automatically using crontab(C) and cron(ADM). 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 an entry that can be added to the root crontab file to run /etc/cleanup each Sunday morning at 5:17:
17 5 * * 0 /etc/cleanup > /dev/nullSee crontab(C) for information about the format of the crontab file.
Although the /etc/cleanup file does not exist by default, you can create one like the one shown in ``Sample cleanup script''
: # # clean up super-user log cp /var/adm/sulog /var/adm/Osulog > /var/adm/sulog # # clean up volcopy log [ -f /var/adm/log/filesave.log ] && mv /var/adm/log/filesave.log \ /var/adm/log/Ofilesave.log > /var/adm/log/filesave.log chown root /var/adm/log/filesave.log chgrp sys /var/adm/log/filesave.log chmod 666 /var/adm/log/filesave.log # # clean up wtmp > /var/adm/wtmp # # clean up miscellaneous files find / -name core -atime +7 -exec rm -f {} \;
Sample cleanup script
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.