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

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
  • Type your comment> @jwgoogle said:
    > 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.

    But it will not occur for all of us. Things like this are isolated to your specific use. Therefore, it requires custom scripting.
    Cyberpanel Managed & Unmanaged Shared & VPS Hosting by Cyberpanel Experts.
    https://www.cyberhosting.org
    You can now earn with the Cyberhosting affiliate scheme. Join today
    https://www.cyberhosting.org/affiliates/
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!