Also, how do I remove 30 days old files in UNIX?
-mtime +30 : This refers to all the files which are older than 30 days. mtime stands for Modification time in Unix. You can change the number based on your requirement. -exec rm {} \ : This is actually the execution command which calls for deletion of all the files filtered by all the above criteria.
Similarly, how do I delete old files in Linux? The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days. The third argument, -exec, allows you to pass in a command such as rm. The {} \; at the end is required to end the command.
Similarly, you may ask, how do I delete 10 days old files in UNIX?
3 Answers
- ./my_dir your directory (replace with your own)
- -mtime +10 older than 10 days.
- -type f only files.
- -delete no surprise. Remove it to test your find filter before executing the whole command.
How do I delete 15 days old files in UNIX?
Unix – Delete files older than a certain number of days using
- Save the deleted files to a log file. find /home/a -mtime +5 -exec ls -l {} \; > mylogfile.log.
- modified. Find and delete files modified in the last 30 minutes.
- force. force delete temp files older then 30 days.
- move the files.
