Skip to Content
Bash & LinuxDelete Old Files

Delete Old Files

Delete files older than a given number of days using find. Choose between modified date, creation date, or access date.

By Modified Date

find /path/to/directory -mtime +60 -delete

By Creation Date

find /path/to/directory -Btime +60d -delete

Note: -Btime (birth time) may not be available on all filesystems/kernels.

By Access Date

find /path/to/directory -atime +60 -delete

Replace 60 with your desired number of days and /path/to/directory with the target path.

Last updated on