Sunday 16 November 2014

Delete log files older than x days on QNAP NAS


The easiest way to delete files older than 'x' days via command line (therefore a cron job can be created to delete it daily) would be:

find /share/Download/messages* -mtime +5 | xargs rm -rf

Then crontab -e and add the following to the bottom

1 0 * * * find /share/Download/messages* -mtime +5 | xargs rm -rf

This will then keep the last 5 days worth of logs.

Good article on editing cron located here : http://wiki.qnap.com/wiki/Add_items_to_crontab