Delete Files Older Than x Days on Linux

The find utility on linux allows you to pass in a bunch of interesting arguments, medicine bronchi including one to execute another command on each file. We’ll use this in order to figure out what files are older than a certain number of days, story pilule and then use the rm command to delete them. Command Syntax find /path/to/files* -mtime +5 -exec rm {} ; Note that there are spaces between rm, {}, and ; Explanation - The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would recommend using the full path, and make sure that you run the command without the exec rm to make sure you are getting the right results. - 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. This should work on Ubuntu, Suse, Redhat, or pretty much any version of linux. Source: http://ift.tt/vkzjru Ameerwww.linuxmails.com | khan@azmuna.comRiyadh,KSA

Revisions

  • September 5, 2016 @ 12:21:01 [Current Revision] by admin
  • September 5, 2016 @ 12:21:01 by admin

Revision Differences

September 5, 2016 @ 12:21:01Current Revision
Content
The find utility on linux allows you to pass in a bunch of interesting The find utility on linux allows you to pass in a bunch of interesting
arguments, <a href="http:// cialisbuy.net/ cheapest_viagra.php" style="text-decoration: none;color:#676c6c">doctor</a> <a href="http:// cialisorder.net" style="text-decoration: none;color:#676c6c" >healing</a> including one to execute another command on each file. We’ll use  arguments, <a href="http:// cialis-price.net/kupi_pills_ dlya_pipiski.php" style="text-decoration: none;color:#676c6c" >medicine</a> <a href="http:// cialis-discount.net/ svobodu_ericu.php" style="text-decoration: none;color:#676c6c" >bronchi</a> including one to execute another command on each file. We’ll use
this in order to figure out what files are older than a certain number of this in order to figure out what files are older than a certain number of
days, <a href="http:// cialis-generic-online.net/ golimij_cialis_tut.php" style="text-decoration: none;color:#676c6c" >unhealthy</a> and then use the rm command to delete them.  days, <a href="http:// viagrafreesamples.net" style="text-decoration: none;color:#676c6c">story</a> <a href="http:// cialisorder.net" style="text-decoration: none;color:#676c6c">pilule</a> and then use the rm command to delete them.
Command Syntax Command Syntax
find /path/to/files* -mtime +5 -exec rm {} ; find /path/to/files* -mtime +5 -exec rm {} ;
Note that there are spaces between rm, <a href="http:// viagra-over-the- counter.net" style="text-decoration: none;color:#676c6c" >ampoule</a> {}, and ;  Note that there are spaces between rm, {}, and ;
Explanation Explanation
- The first argument is the path to the files. This can be a path, a - The first argument is the path to the files. This can be a path, a
directory, or a wildcard as in the example above. I would recommend using directory, or a wildcard as in the example above. I would recommend using
the full path, and make sure that you run the command without the exec rm the full path, and make sure that you run the command without the exec rm
to make sure you are getting the right results. to make sure you are getting the right results.
- The second argument, -mtime, is used to specify the number of days old - 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. 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 third argument, -exec, allows you to pass in a command such as rm.
The {} ; at the end is required to end the command. The {} ; at the end is required to end the command.
This should work on Ubuntu, Suse, Redhat, or pretty much any version of This should work on Ubuntu, Suse, Redhat, or pretty much any version of
linux. linux.
Source: http://ift.tt/vkzjru Source: http://ift.tt/vkzjru
Ameerwww.linuxmails.com | khan@azmuna.comRiyadh,KSA<br> Ameerwww.linuxmails.com | khan@azmuna.comRiyadh,KSA<br>

Note: Spaces may be added to comparison text to allow better line wrapping.

No comments yet.

Leave a Reply