Automatically delete or move to another folder, files older than X days [Linux / SSH Commands]

countless are options si commands in linux, and I think I would have the heads if I had the option of moving from one folder to another 120 some files older than days.
Here is how we can move some files older than X days:

Commands via SSH :

find / home / path / files * -mtime + 120 -exec mv / new / destination / {} \;

If you want to delete all fisirele older 30 days in a folder ...

find / path / file * rm -f -mtime + 30 -exec {} \;

Must necessarily leave spaces -Mtime, Number of days, -Exec (Command line continues) rm (Removal order - remove) argument " -f "(Delete force) {} and \ ;.

It is possible that on some distributions of Linux, "-f" not work. Dispose of this argument in line and everything will be ok.

* Tested on CentOS 5.3 (FT).

Automatically delete or move to another folder, files older than X days [Linux / SSH Commands]

About the author

Stealth LP

Founder and editor Stealth SettingsIn 2006 date.
Experience on Linux operating systems (especially CentOS), Mac OS X, Windows XP> Windows 10 and WordPress (CMS).

Leave a Comment