Script to clean php session files — CyberPanel - WebHosting Control Panel for OpenLiteSpeed
CyberLoader

Script to clean php session files

Last week I had a server that was hosting over 50 sites stop responding correctly.

The source of the problem was that the server had used up the available quota of inodes. In this directory were 800,000 old php session files:

/var/lib/php/session/

I think that cyberpanel should add a cron script that runs either every day or every week that delete all session files older than 7 days.

This will prevent this issue from occurring again for all of us.

Comments

  • Here is the script I added to my servers:

    #!/bin/bash
    export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    path_of_session_files=/var/lib/php/session
    find $path_of_session_files -type f -cmin +720 -name "sess_*" -delete
Sign In or Register to comment.
CyberPanel Discord

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion