[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: speed up /etc/cron.d/php5

On 03/02/2012 03:13 PM, dmitrijs.samsonovs@gmail.com wrote:
> Hello, everybody!
> I have server with php storing sessions in files.
> Due to Debian changes session aging is managed by cron /etc/cron.d/ php5.
> Which take a looong time (10-20m) to accomplish in my situation due to high session count (~10k).
> The slowest part of cron is fuser call and if I understand this correctly the only purpose of it to avoid currently opened file deletion.
> If so, is this workaround appropriate?
> 09,39 *     * * *     root   [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -ignore_readdir_race -type f -cmin +$(/usr/lib/php5/maxlifetime) `/usr/bin/lsof -F n +d /var/lib/php5/ | /bin/grep -o "sess_.*" | /usr/bin/tr -d "\n\r"| sed -e "s/sess_/ ! -name sess_/g"` -delete
> The idea is to generate a list of additional options for find excluding from result all files which are currently opened by any process.
> It may be not so good if there are many opened session files, but in my environment I can see only few at a time.
> Thank you.
> Dmitry Samsonov

There has been very long discussion about this piece of scripting
in the PHP maintainer list. I think that the Alioth list would be a
more appropriate place to talk about it.

FYI: pkg-php-maint@lists.alioth.debian.org


Reply to: