Automatic PHP session cleanup

#1
Does OLS not come with a cron job to automatically clean up PHP sessions? We just had quite a bit of downtime due to OLS filling up /tmp with PHP session files. I had assumed there would be a cleanup cron job in place (Like there is with the standard PHP binaries that come from the OS Repos) but if there is, I'm not seeing it.

What is the correct way to clean up PHP sessions in OLS? How are sessions dealt with in the commercial version of Litespeed? (Asking because I have several Litespeed licenses for other servers and I want to make sure those are being cleaned up properly)
 

Cold-Egg

Administrator
#2
#3
Sorry, I appreciate your reply but you didn't answer the question at all. I understand how sessions work, and I know that PHP has garbage collection built in. I asked two very specific questions:

1. What is the correct way to clean up PHP sessions in OLS?
2. How are sessions dealt with in the commercial version of Litespeed? (Asking because I have several Litespeed licenses for other servers and I want to make sure those are being cleaned up properly)

/tmp didn't fill up. I said OLS is filling up /tmp with session files. A reboot caused the startup to freeze because of the sheer number of files in /tmp. It wasn't a space issue, just the fact that sessions hadn't been removed for the last 6 months (Since we switched to OLS from nginx).

On an Ubuntu server, UBUNTU ships with a cron job that fires twice per hour and runs /usr/lib/php/sessionclean. That script, in turn, removes all session files from /etc/php/{version}. This is the way it's handled in Ubuntu, and it cleans up sessions from the versions of PHP in the Ubuntu repositories. Since Litespeed is storing its PHP in a different location, this cleanup script doesn't remove the sessions. And since Litespeed ALSO isn't removing the sessions, we end up with this mess of millions of session files in /tmp because nothing ever deleted them.

So again, I ask my above two questions. What is the preferred method of cleaning up sessions in OLS, and how is the commercial product cleaning up sessions (Again, asking here because I have 6 Commercial licenses and I need to make sure that they are cleaning up sessions appropriately as well)
 
#4
The session files have not yet led to a failure for me, but I have just wondered about countless session files in the /tmp directory.

PHP also has a built-in garbage collector, but this is explicitly deactivated in php.ini with session.gc_probability = 0. In combination with a missing cronjob for the session cleanup, a disaster is of course inevitable.

How did you solve the problem?

On the Internet you can often find approaches such as:
Code:
find /tmp/ -ctime +7 -type f  -name "sess*" | xargs rm
 
#6
I have the same issue with Litespeed Enterprise... /tmp folder keep on full and the webserver was stucking because nothing can create tmp file. Have any fix instead of
Code:
find /tmp/ -ctime +7 -type f  -name "sess*" | xargs rm
 
Top