|
Too many files to handle that way
Although this question is an old one, this info may be handy for someone having the same issue;
The error message is happening because when the wildcard * is used with a command, Linux will go through the directory and build a list of the files it's going to delete. Since there's so many of them, it runs out of room to store the list of files.
One way around it is to use the find command with the -exec option. This will run a separate rm command for each file found by find, rather than trying to do them all at once.
find /var/spool/mqueue -type f -exec rm -f {} \;
-type f : searches for files only
-exec : do the following command. {} is where find will put the name of the find result to be acted on by the command.
rm -f : include the -f force option to stop it prompting you to remove every file
You could add other things to the find command , such as
find /var/spool/mqueue -type f -mtime +5 -exec rm -f {} \;
-mtime +5 will only delete message older than five days, so you don't need to delete the whole queue
Hope that helps someone out there.
|