delete php sessions to free inodes.
Quick How To for the Impatient
1. Run following script to download clean-php-session-files.sh script
-------------------------------------------------------------------
mkdir /root/bhscripts
cd /root/bhscripts
wget http://files.bytehouse.co.uk/clean-php-session-files.sh
chmod 755 /root/bhscripts/clean-php-session-files.sh
-------------------------------------------------------------------
2. Configure a cron job to hourly delete old session files.
-------------------------------------
0 * * * * /root/bhscripts/clean-php-session-files.sh delete >/dev/null 2>&1
-------------------------------------
Full details here... https://kb.bytehouse.co.uk/content/12/42/en/script-to-delete-php-session-files-to-keep-inode-usage-to-minimum.html
Big thanks to Bytehouse KB
Scipt content:-
#!/bin/bash
deletepermission=$1
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
PHPSESSIONPATH=$(php -i 2>/dev/null | grep -w session.save_path | awk '{print $3}' | head -1);
PHPSESSIONLIFETIME=$(php -i 2>/dev/null | grep -w session.gc_maxlifetime | awk '{print $3}' | head -1);
PHPSESSIONLIFETIMEMINUTE=$( expr $PHPSESSIONLIFETIME / 60 );
if [[ $deletepermission = "delete" ]]
then
find $PHPSESSIONPATH -type f -cmin +$PHPSESSIONLIFETIMEMINUTE -name "sess_*" -exec rm -f {} \;
else
echo "
PHPSESSIONPATH=$PHPSESSIONPATH
PHPSESSIONLIFETIME=$PHPSESSIONLIFETIME
PHPSESSIONLIFETIMEMINUTE=$PHPSESSIONLIFETIMEMINUTE
If you wish to delete session files in $PHPSESSIONPATH, please run the script as given below.
-------------------------------------------------------
/root/bhscripts/clean-php-session-files.sh delete
-------------------------------------------------------
";
fi