[php-maint] speed up /etc/cron.d/php5
dmitrijs.samsonovs at gmail.com
dmitrijs.samsonovs at gmail.com
Mon Mar 12 07:42:44 UTC 2012
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/sed -nre 's/.*(sess_.*)$/ ! -name \1/p' | /usr/bin/tr -d "\n\r"` -delete
The idea is to generate a list of additional options for find which will exclude all files which are currently opened by any process from result.
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 even with 10k sessions.
Thank you.
Dmitry Samsonov
More information about the pkg-php-maint
mailing list