Question

I have the following command which deletes files that are one day old and that are of mp3 file type.

find /home/get/public_html/audio -daystart -maxdepth 1 -mtime +1 
-type f -name "*.mp3" |xargs rm -f

The problem with this is when I run it, it sometimes says,

"fork": resource xargs not available.

Does this mean this command first finds the file and then starts many process to delete each file?

How can I (when a file is found) immediately delete it rather than it being piped to xargs?

I can't use that -delete ("invalid predicate").

Was it helpful?

Solution

what about trying:

 find /home/get/public_html/audio -daystart -maxdepth 1 -mtime +1 
    -type f -name "*.mp3" -exec rm -f {} \;

OTHER TIPS

Check your man page for find, it might support -delete, making it as simple as

find /home/get/public_html/audio -daystart -maxdepth 1 \
   -mtime +1 -type f -name "*.mp3" -delete

Perhaps you can use the "-delete" flag to find, instead of piping to xargs?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top