$> sudo crontab -e
#then add a line like this:
* * * * * find /path/to/files/ -type f -mtime +<n> -exec rm -rf {} \;
#Ex:
#Delete "*.txt" files older than 1 day from /tmp folder every day at 2:00am:
0 2 * * * find /tmp/* -type f -mtime +1 -exec rm {} \; #files
0 2 * * * find /tmp/* -type d -mtime +1 -exec rm -rf {} \; #folders
Add lines like these to crontab in order to delete older-than-n-days files from specific folder.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.