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

speed up /etc/cron.d/php5

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

Reply to: