Comment posted How to delete million of files on busy Linux servers (Work out Argument list too long) by .
Recent comments by
Tags: Auto, client, deletec, deleteJust, Deleting, deleting files, Disk, downside, Draft, exec rm, eye, file, file deletion, freebsd, half a million, hard disk, heavy load, hipo, junk files, Linux, linux servers, maxdepth, multiple files, multitudes, multple, nbsp, new ways, noah, nomatter, number, obsolete files, operation, option, point of view, printing, quot, real time, rm command, servers work, Shell, ssh, terminal, test, time, tmp, type, unlink
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0
1) Why bash loop does not slow disk, compared to find? What about adding sleep to perl? 2) >keeping millions of files within the same directory is very stupid Is the following true: Even deleted files in directory reduce ext3 performance of ls. It reads inodes marked as free, which were not free. It takes time, compared to virgin inodes.
View CommentView CommentMozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0
You can even use rsync command to delete millions of files in linux by syncing with a blank directory.
View CommentView CommentThe below post does a study on file deletion.
http://www.slashroot.in/which-is-the-fastest-method-to-delete-files-in-linux
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
For me the bash loop seems to work best on my production server – trying to get rid of millions of session files.
View CommentView CommentThanks for sharing your solutions – the find method simply couldnt do it because of the amount of files.
I can also recommend the rsync method from mohan
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0
Can you explain why you call stat() prior to unlink?
# perl -e ‘for(){((stat)[9]<(unlink))}'
This "tip" is being parroted around the internet by people who don't understand what its for, and my reasonably thorough testing indicates the stat() call slows it down.
http://www.quora.com/Linux-why-stat+unlink-can-be-faster-than-a-single-unlink/answer/Kent-Fredric?__snids__=658761123&__nsrc__=2#
View CommentView CommentMozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36
Try “Long Path Tool ” is also useful in situations where you see these error messages: Cannot read from source file or disk, there has been a sharing violation, cannot delete file or folder, the file name you specified is not valid or too long, the source or destination file may be in use and many other file managing errors.
View CommentView CommentMozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2560.0 Safari/537.36
you might want to try moving all the non-related files outside the directory, and give it one shot: rm -rf DIR
View CommentView CommentMozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2560.0 Safari/537.36
a even better way is: write a tool in c to remove the files, you can hard-encode the direcory path in the code, and sleep periodically, to avoid stressing the server.
View CommentView CommentMozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0) Gecko/20100101 Firefox/56.0
You're making it far too complex to yourself.
Just execute 'rm -f [yourneeds] &' and set process priority to a lower digi, using 'nice'.
Find the process id (pid) with 'ps' and give it a new priority:
ps -o pid,comm,nice -p 594 # replace 594 with your process id / pid
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0) Gecko/20100101 Firefox/56.0
By the way, some Linux flavours also hold the 'nice' and 'renice' command. Check your MAN-pages if your version has them.
View CommentView CommentMozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Hey Marco,
Thanks for the hint about renice and nice, that’s pretty adequate.
Best,
Georgi
View CommentView CommentMozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0) Gecko/20100101 Firefox/56.0
You're making it far too complex to yourself.
Just execute 'rm -f [yourneeds] &' and set process priority to a lower digi, using ''renice'.
Find the 'nice'for your process id (pid) with 'ps' :
ps -o pid,comm,nice -p 594 # replace 594 with your process id / pid
Then set the new priority for the process ID:
renice 10 -p 595 # replace 594 with your process id / pid
It is even possible to start the process as a 'nice'process:
nice -n 10 rm -f [yourneeds]
and renice it afterwards using 'renice'.
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
If you need to delete a pattern contained in all files (e.g. delete just some of the files) you can use this command: cd /path/to/directory/; find . -type f -mtime +5 -print |grep -i 'WF_LOG_'| xargs rm -f
View CommentView Comment