[php-maint] php5 cron job performance (barely) suggestion

Steve Langasek vorlon at debian.org
Thu May 10 06:34:45 UTC 2007

On Thu, May 10, 2007 at 07:22:29AM +0200, Trixter aka Bret McDanel wrote:
> (root) CMD (  [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin
> +$(/usr/lib/php5/maxlifetime) -print0 | xargs -r -0 rm)

> that cronjob can likely be changed to prevent using 'xargs' which means 1
> less process, little less file activity, bleh like this matters that much
> given how infrequently its called, but still, to quote a tv advert for a
> local grocery store "every little helps" :)

> instead of -print0 try   -exec rm {} \;

> if you dont know, exec must be terminated with a ; which generally needs to
> be escaped, and {} is replaced by the name of the file that find found.

> I am unsure if there is a reason to not do this,

Yes: -exec rm {} \; is not safe with filenames containing special
characters, including but not limited to spaces.

It's also a false optimization, because while xargs rm can combine multiple
files onto a single commandline, -exec rm {} \; must fork a separate process
for every matching file.

Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
vorlon at debian.org                                   http://www.debian.org/

More information about the pkg-php-maint mailing list