If you are using Ubuntu inside Windows using WSL, you will have the SysV instead…
Delete Files Older Than 30 Days on Linux
Finding and cleaning old files which are no longer necessary after a specific period is very important that you need to do. This will save you some disk space and also make your system run faster. If you did not clean old files from your system yet, we give you the quick way to do that. This brief tutorial will show you how to find and delete files that are older than X days in Linux and Unix-like systems.
find /path/to/ -type f -mtime +30 -name '*.log' -execdir rm -- '{}' \;
Explanation:
find
: the unix command for finding files/directories/links and etc./path/to/
: the directory to start your search in.-type f
: only find files.-name '*.log'
: list files that ends with.log
.-mtime +
30: only consider the ones with modification time older than 30 days.-execdir ... \;
: for each such result found, do the following command in...
.rm -- '{}'
: remove the file; the{}
part is where the find result gets substituted into from the previous part.--
means end of command parameters avoid prompting error for those files starting with hyphen.
This Post Has 0 Comments