If there is no files exists to remove older than 10 days, It should not do anything. How can I improve this to only delete files older than x days (e.g. 1 05-23-2012 rajeshjohney Registered User 3, 0 Delete files older than 10 Days in a directory Hi All I want to remove the files with name like data.csv from the directory older than 10 days. Once you have decided that these files are no more requires then go ahead and delete it, using one of the following command. 1 Im currently using this cron job to delete stalled temp files in a particular location. home/linuxgeek/Downloads/preferencessystemnetwork_103783.png home/linuxgeek/Downloads/Apps-preferences-system-network-icon_31759.png home/linuxgeek/Downloads/tech_ethernet_icon_156953.png home/linuxgeek/Downloads/Teddy-320kbps-MassTamilan.io.zip home/linuxgeek/Downloads/Karnan-320kbps-MassTamilan.fm.zip Starting cmd.exe with option /c just to run WinRAR.exe is of course completely useless here. ' inside the command line to execute by FORFILES must be escaped with \. find /home/linuxgeek/Downloads -type f -mtime 30 -print PS: Run in a command prompt window forfiles / and read the output usage help if you really want to use this Windows command ever again. ![]() If not, delete them using the below command. The below output will allow you to check whether these files are needed before they are deleted. The results from the find command will be sent into the rm command. 1) Search and Delete files older than 30 daysįirst, we will find out all files older than 30 days under the ‘/home/linuxgeek/Downloads’ directory. The rm commands -exec command-line argument allows us to delete files. For example, time 2 = 2*24 hours (2 days). The time argument consider an input value as ’24 hours’. Mtime (File Last Modify Time) – mtime shows when you modify, append or update a file content. ![]() To delete files older than 30 days on your Linux server, you need to use multiple commands together such as find command, ‘mtime’ command, ‘exec’ command and rm command. ![]() Please make sure these files are no longer needed, as it will not ask for your confirmation before deleting the files.Īre you wondering how to delete older files in your Linux system? This quick guide show you how to find and remove files older than 30 days in Linux. It is a best practice to find and remove old or unused files from the Linux system after a certain period of time, as this will free up some space on the system, which can be used for some other purpose.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |