How do I uninstall older than 30 days in Linux?

How do I delete 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.

How can I delete files older than a certain date in Linux?

For just files find /path ! –type f -newermt “YYYY-MM-DD HH:MM:SS” -delete . It saves you from having to pipe everything through xargs, and having to handle filesnames with spaces or other disruptive characters.

How do I remove old Linux logs?

How to clean log files in Linux

  1. Check the disk space from the command line. Use the du command to see which files and directories consume the most space inside of the /var/log directory. …
  2. Select the files or directories that you want to clear: …
  3. Empty the files.
IT IS INTERESTING:  Quick Answer: What is Ubuntu TLP?

How do I delete files older than 7 days UNIX?


  1. find : the unix command for finding files/directories/links and etc.
  2. /path/to/ : the directory to start your search in.
  3. -type f : only find files.
  4. -name ‘*. …
  5. -mtime +7 : only consider the ones with modification time older than 7 days.
  6. -execdir …

How do I delete files older than 180 days Linux?

As before, the -mtime parameter is used to find files older than X. In this case, it’s older than 180 days. You can either use the -delete parameter to immediately let find delete the files, or you can let any arbitrary command be executed ( -exec ) on the found files.

How do I delete 10 days old files in UNIX?

3 Answers

  1. ./my_dir your directory (replace with your own)
  2. -mtime +10 older than 10 days.
  3. -type f only files.
  4. -delete no surprise. Remove it to test your find filter before executing the whole command.

How do I delete 2 days old files in Linux?

So make sure you add the -delete as the last argument. IE: find . -delete -mtime +5 will delete EVERYTHING in the current path. With option -mmin in place of -mtime , you can specify time in terms of minutes.

How do I delete one week old files in UNIX?

You could start by saying find /var/dtpdev/tmp/ -type f -mtime +15 .

4 Answers

  1. -exec rm -f {} ; (or, equivalently, -exec rm -f {} ‘;’ ) This will run rm -f on each file; e.g., …
  2. -exec rm -f {} + …
  3. -delete.

How do I delete a Linux Month wise?

How to delete all files before a certain date in Linux

  1. find – the command that finds the files.
  2. . – …
  3. -type f – this means only files. …
  4. -mtime +XXX – replace XXX with the number of days you want to go back. …
  5. -maxdepth 1 – this means it will not go into sub folders of the working directory.
IT IS INTERESTING:  How do I search in Linux terminal?

Where is the last 30 days file in Linux?

How To Find Files Modified in Last 30 Days in Linux

  1. Use + with number of days to search file modified older that X days.
  2. Use – with number of days to search file modified in last X days.

How do I delete old logs Logrotate?

Solution: clean logs created by cron

set maxage to 7. This will remove files which have last modification time higher than 7 days. dateext is used just to ensure, logrotate searches for older files looking like rotated.