In this article I will show example of cron job for Linux to delete files older than 10 days.
How to Edit Crontab file
To edit or create new crontab file, type the following command:
$ crontab -e
Cron Job To Delete Files Older Than X Days
In crontab editor type:
0 0 * * * /usr/bin/find /target_directory -name "*.txt" -type f -mtime +10 -exec rm -f {} \;
Change /target_directory and “*.txt” as you need.
Cron expression 0 0 * * * means cron job will run every day at 12:00 AM.

You can read more about cronjob.
Delete Files Older Than 7 Days
If you like what you are reading, please:
Summary

Article Name
Cron Job for Linux To Delete Files Older Than X Days
Description
How to delete old files in Linux using cron job. Example of cron job for Linux to delete files older than 10 days. Cron job will run every day
Author
ARSTECH
Publisher Name
ARSTECH
Publisher Logo
