diff options
| author | Ondřej Surý <ondrej@sury.org> | 2012-11-29 08:48:20 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2013-01-16 09:02:17 +0100 |
| commit | 5ee6bc14c5bf0788d58963cdfc8de2fdcd01c699 (patch) | |
| tree | 46bf1b9366fb24e63a815801d64b3cc3f00c0dfe | |
| parent | 8f53d6e97edcc277d553c6c50c80bebac534de06 (diff) | |
| download | php-5ee6bc14c5bf0788d58963cdfc8de2fdcd01c699.tar.gz | |
Introduce new (hopefully slightly smarter) way of not deleting still used session files
| -rw-r--r-- | debian/php5-common.php5.cron.d | 2 | ||||
| -rwxr-xr-x | debian/rules | 1 | ||||
| -rw-r--r-- | debian/sessionclean | 7 |
3 files changed, 9 insertions, 1 deletions
diff --git a/debian/php5-common.php5.cron.d b/debian/php5-common.php5.cron.d index bed06e3ef..abf04d241 100644 --- a/debian/php5-common.php5.cron.d +++ b/debian/php5-common.php5.cron.d @@ -4,4 +4,4 @@ # files, or 24 minutes if not defined. See /usr/lib/php5/maxlifetime # Look for and purge old sessions every 30 minutes -09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -ignore_readdir_race -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete +09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionsclean /var/lib/php5 $(/usr/lib/php5/maxlifetime) diff --git a/debian/rules b/debian/rules index c89c7c868..509786ec3 100755 --- a/debian/rules +++ b/debian/rules @@ -622,6 +622,7 @@ install: build # install common files install -m755 debian/maxlifetime debian/php5-common/usr/lib/php5 + install -m755 debian/sessionclean debian/php5-common/usr/lib/php5 install -m755 debian/php5enmod debian/php5-common/usr/sbin/php5enmod ln -s php5enmod debian/php5-common/usr/sbin/php5dismod diff --git a/debian/sessionclean b/debian/sessionclean new file mode 100644 index 000000000..bd95db8b5 --- /dev/null +++ b/debian/sessionclean @@ -0,0 +1,7 @@ +#!/bin/sh + +# first find all used files and touch them (hope it's not massive amount of files) +lsof -w -l +d "${1}" | awk -e '{ if (NR > 1) { print $9; } }' | xargs -i touch -c {} + +# find all files older then maxlifetime +find "${1}" -depth -mindepth 1 -maxdepth 1 -type f -ignore_readdir_race -cmin +${2} -delete |
