How to auto-clear the virtual server php sess_ files more often?

SYSTEM INFORMATION
OS type and version almalinux 8.10
Webmin version 2.202
Virtualmin version 7.20.2

According to the second-to-last post here:

Ok, the next release of Virtualmin will clean up sess_* files in each domain tmp dir that are older than 7 days by default.

Even if this was working, my /home/site.net/tmp/ dir is not cleared fast enough, and the server goes down whenever more than 20K session files are created (which happens in a weekly basis).

In case that setting to empty the sess_ files really exists, where do I change the default “7 days” to something more reasonable like, 1 hour? Thanks

I think, in the php.ini file and it is called garbage collection possibly.

I can’t remember the exact options to change.

This may help.

The problem is that the native garbage collection process does not apply to virtual servers for some technical reason, as described in the linked topic.

Thanks, I’ve added this into my virtual server’s Edit Configuration Manually conf file:

php_value[session.gc_maxlifetime] = 3600

Let’s hope this is enough to auto-clear these session files.

Then this might be a bug. @Ilia what do you think?

You should reduce the number of days for cleanup using the “Cleanup PHP session files after” option on the “System Settings ⇾ Virtualmin Configuration: PHP options” page.

@Jamie, though the bug will appear in FPM mode if a custom session.save_path is configured. We should also take the FPM config into account.

@inuya5ha, I’ve been digging deeper into this issue and have found some additional problems beyond the incomplete support for FPM. I will address these.

However, are you using Nginx or Apache as your webserver? Also, which PHP execution mode are you using?

1 Like

@Jamie, please check these ones out:

and

@Ilia I’m using Apache version 2.4.37 and the PHP-FPM execution mode, if you need to check the VPS personally let me know how to give you access, it’s not like I have nuclear launch codes hosted there… thanks.

I’ve just set the Cleanup PHP session files value to 1, let’s see if this helps. Anyway, I’ve modified my site to avoid sessions for guest users, meaning that the number of session files has dropped dramatically (and some functionality of my site is probably gone too)

Thank you, but there’s no need; I’ve already reproduced and fixed everything in this regard.

If you have status collection enabled in Virtualmin configuration and the session directory defaults to ~/tmp, it will still work properly and clear the files!

The upcoming Virtualmin release, either 7.30.4 or 7.40.0, will include support for custom values for the session.save_path directive in PHP-FPM mode as well.

1 Like

Thanks, they look good!

1 Like