Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sathish-io/4732524fc46dffb79718 to your computer and use it in GitHub Desktop.
Save sathish-io/4732524fc46dffb79718 to your computer and use it in GitHub Desktop.
Linux - Find files that are older than 1 day
Find files that are older than 1 day with file name 'LOGFILE', and delete them.
find /var/log/ -type f -mtime +1 -name '*LOGFILE*' -exec rm {} \;
We can put this delete command in a script say deleteOldLogs.sh and add it in cron entry to run every day,
crontab -l
0 0 * * * /usr/sathish/Scripts/deleteOldLogs.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment