php individual tmp sessions not deleted

Discussion in 'Installation/Configuration' started by asticot, Dec 11, 2009.

  1. asticot

    asticot New Member


    On my ISPCONFIG server (running on debian 5), I have a little problem with the automatic deletion of tmp files that are in /var/www/clients/clientX/webX/tmp/

    In the /etc/php5/apache2/php.ini file, I have :

    ; This is disabled in the Debian packages, due to the strict permissions
    ; on /var/lib/php5. Instead of setting this here, see the cronjob at
    ; /etc/cron.d/php5, which uses the session.gc_maxlifetime setting below.
    ; php scripts using their own session.save_path should make sure garbage
    ; collection is enabled by setting session.gc_probability
    ;session.gc_probability = 0
    session.gc_divisor = 100

    ; After this number of seconds, stored data will be seen as 'garbage' and
    ; cleaned up by the garbage collection process.
    session.gc_maxlifetime = 1440

    The cronjob /etc/cron.d/php5 runs every 30 minutes but it delete only tmp files that are in /var/lib/php5

    Since all my website have a apache directive :

    php_admin_value session.save_path /var/www/clients/client1/web1/tmp

    There are many location for tmp files. And so the problem is that all tmp files of each website are not deleted.

    Do you know what to do ?
    - Should I enabled "session.gc_probability = 1" in my php.ini ?
    - Should I remove the session.save_path for each website ?
    - Should I write a script to manually delete tmp files ?

  2. till

    till Super Moderator Staff Member ISPConfig Developer

    This is a problem in php. If a custom session tmp dir is defined, php will not care about removing sessions files anymore. The best way to solve this is to write a custom script. We will add such a script in ispconfig too to fix this php problem.
  3. asticot

    asticot New Member

    OK thank you Till,

    For information, here is what I am doing now manually :

    In each tmp dir :
    find -cmin +24 | xargs rm

    This command will delete all files that were not changed for 24 minutes.
  4. xaver

    xaver New Member


    i had this Problem twice.
    If i open a session and switch from mod_php to fastcgi + suexec the problem start because www-data is the old User and the new user is web??:client??.
    The user can't change the file anymore.

  5. gzx21

    gzx21 New Member


    I was wondering whether this problem was fixed. I am using ISPConfig version (Debian Wheezy, Apache) and it still seems to be an issue.

    Till, perhaps if the deletion script is not in the production, would you be so kind as to provide the script if you managed to write it?

    Thank you very much.
  6. asticot

    asticot New Member

    Yes I confirm this issue was fixed a long time ago.
  7. gzx21

    gzx21 New Member

    OK, so how is it possible that it's still happening in my installation? Is it possible that I might have misconfigured something? I closely followed the guides on HowtoForge, nothing really special.

    Is it possible that these log messages are related to the problem? They appear every 30 minutes in my local mail:

    Thank you.
  8. Gwyneth Llewelyn

    Gwyneth Llewelyn New Member

    @gzx21 You can indeed remove the # on /etc/php5/cli/conf.d/ming.ini and it should make those nasty errors disappear.
    @asticot, @till — I know I'm posting three years later, but my ../tmp directories are full of eon-old sessions, and
    /usr/lib/php/sessionclean most definitely is not going to delete them, and I don't see anything in
    /usr/local/ispconfig/server/lib/classes/cron.d which might be deleting those session files. Where exactly is that 'new' custom script?
  9. Gwyneth Llewelyn

    Gwyneth Llewelyn New Member

    Ah... I was doing the wrong greps :p Apparently, it's being run from after the line:
    // Cleanup website tmp directories​
    Ok so far, but apparently this is not working. It shouldn't be a permissions problem, since, as far as I can see, this script is being run by root. Hm.
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    Does the command work when you run it manually?

    cd /var/www/clients/client0/web1/tmp; find . -mtime +1 -name 'sess_*' | grep -v -w .no_delete | xargs rm > /dev/null 2> /dev/null
  11. Gwyneth Llewelyn

    Gwyneth Llewelyn New Member

    It works in the sense that it does run without errors; but, as said, my session files seem to start all with phpXXXXXX (where XXX are random alphanumeric characters), so of course this will not catch them.

    I can run
    find . -mtime +1 -name 'php*' | grep -v -w .no_delete | xargs rm > /dev/null 2> /dev/null
    instead, and of course this will delete them all. Interestingly enough, though, it seems that my current configuration does not write any session files...

Share This Page