CRONTAB JOB TO CLEAN OLD TRACE OR LOG FILES IN LINUX

Use the below command to housekeep the linux server where old trace files fill space often and cause distraction from critical tasks. ***Warning***, i have given a dot ‘.’ symbol in find command to detect all tracefiles in all mount points and remove them. If you are not sure what you do, then specify the absolute or relative path of log or tracefile directory ,test it manually and then schedule in crontab like this instead of using -name option

find /apps01/diag/rdbms/orcl19x/orcl19x/trace/*.trc -type f -mtime +1 -exec rm -rf {} \;

-bash-4.2$ crontab -e
find . -name *.trc -type f -mtime +3 -exec rm -rf {} \;

Below is the cronjob scheduled for every wednesday and saturday at 1AM to clean up the old trace files

-bash-4.2$ crontab -l
0 1 * * 3,6 find . -name *.trc -type f -mtime +3 -exec rm -rf {} \;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s