Temp folder overflow

Good day everyone.

Recently started to experience a temp folder overflow with session files to the point, where if I open the folder it just freezes. Despite saving sessions being a normal behavior it started to take up too much space. So I wonder - does Hestia have any cleanup feature? Or setting up a cron task will be that way to solve this?

There is an cronjob set up in /etc/cron.d/php

# Look for and purge old sessions every 30 minutes
09,39 *     * * *     root   [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi

Indeed there is, I guess in my case it just doesn’t work. Is there a possibility this is caused by the latest update? I haven’t had this issue before. Would you suggest rebuilding Hestia?

I also checked syslog and it looks like the php script in cron.d is running, however the sess files are still not deleted. Any thoughts?

Just a quick thought on that… Maybe these sessions are not old enough to be deleted? Maybe something is creating too many sessions (a bot or attack) ?

I thought so too, but everything is very regular - not too much traffic, no sudden peaks. Although some sessions are pretty old, at least few days +

Have you run the command manually to see if it throws an error?

Have you checked the permissions?

Are those files not being closed by the system? Maybe it is a bad designed software that is leaving open files behind.

I had a problem with running out of inodes because of hundred thousand of PHP session files did not get deleted automatically. But it was when using VestaCP.

I just created a naive script below that iterates all users tmp folder :grinning: Using this script I now know the fact that I cannot find PHP session files started with “sess_*” older than 7 days on my 3 web servers.

I wonder where the setting that deletes PHP session files older than 7 days comes from? But well at least I feel safe from inodes running out again :grin:

Save this script to /tmp/check-tmp-files.sh
chmod +x /tmp/check-tmp-files.sh
cd /tmp
./check-tmp-files.sh 7 (accept 1 argument as number of days to check to be older than)

#!/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

if [ "$1" = "" ]; then
	days=0
else
    days=$1
fi

all_user=$(/usr/local/hestia/bin/v-list-users plain |cut -f 1)

# Loop all users
for user in ${all_user[@]}; do
    
	user_tmp_dir="/home/$user/tmp"
    echo; find $user_tmp_dir -type f -mtime +$days  # print the list files found. comment out this line if not needed.
    found=$(find $user_tmp_dir -type f -mtime +$days | wc -l)
    total=$(($total + $found))

done

echo
echo "TOTAL FOUND = $total FILES"
echo
1 Like

Just to inform, hestia has a auto cleanup for session files:

3 Likes

Execute /usr/lib/php/sessionclean no error, but no use though - files are still there. The permissions are fine as well - the script starts under root, successfully finishes, but no impact on old sessions -
CRON[1224991]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
Systemctl status cron - return as running, same with phpsessionclean.service and timer - running properly. I am definitely missing something out, but not sure what causes the issue

maybe check the logfiles if the sessionclean command throws any errors. could be either a permission issue. or it is dependant on the php-version and settings, the cli command might simply not be aware of specific session folders?