Help - Millions of sess_ files in tmp folder
PermalinkMy client's files/tmp folder keeps filling with millions of files that begin with sess_ presumably files that keep track of session data. They are not being cleaned out automatically, and they take forever to clean out manually unless we do so frequently. What can be done about this?
Best,
Joey
http://ca.php.net/manual/en/session.configuration.php#ini.session.g...
Ugh ugh ugh.
I sure hope this is fixed in 5.6.1. Really feeling like I'm getting dinged for my pre-upgrade due diligence here. This was supposed to be a simple, one-click upgrade. :(
(I checked my php configuration and all seemed to be in order.)
If I understasnd, the php.ini setting only destroyes sessions in the default /tmp/ folder.
But concrete5 saves them in /files/tmp/ under the install folder.
The server does not clean this folder by default?
http://www.concrete5.org/marketplace/addons/cache-vac/...
http://www.concrete5.org/developers/bugs/5-6-1-2/default-ubuntu-lam...
Here's also some information about it:
http://www.php.net/manual/en/function.session-save-path.php#98106...
I dug through the code and found where c5 determines it's storage loactions.
'DIR_TMP' is determined on line #150 of [root]/concrete/core/helpers/file.php
'DIR_SESSIONS' is determeined on line #29 of [root]/concrete/startup/file_permission_config.php
As soon as I defined these variables in my site.php file as noted above, the problem disappeared on my server. I would recommend asking your host what you need to set these to in order for their 'garbage collection' routines to clean them up.
0 0 * * * find /home/USERNAME/public_html/files/tmp/sess_* -mtime +0 -exec rm {} \;
This only deletes files that are older than one day.
I've even run to situation where the millions of session files have prevented concrete5 from working because of the /tmp folder being unusable (some file system specific issue with too many files in a dir).
Here is the job file "clean_temp_sessions.php" we created along with install instructions.
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); /* Install Copy this file to /jobs Dashboard > System & Settings > Automated Jobs Install "Clean Temp Sessions" Automate the job to your liking */ class CleanTempSessions extends Job { public function getJobName() { return t('Clean Temp Sessions'); } public function getJobDescription() { return t('Cleans up PHP sess files from /files/tmp that are older than one day.');
Posted with love in case anyone else finds it useful. ^_^
Cheers!
Sorry for the bad pun, but... great job :)
jordi
I have the same problem but I don't know how to use your code.
In particular i didn't understand where I have to put the code.
Please can you help me?
thank you very much
First, have you checked to see if there are a lot of session files inside the /files/tmp folder?
If so, follow these directions to install ForestMist's code:
1) Copy all the lines of code from ForestMist's post to your clipboard. (click the link below it to see all the code)
2) Create a new, blank file in a pure text editor (like Notepad++ or just Notepad) and paste the code into this new file.
3) Save the files as "clean_temp_sessions.php"
4) Upload this new file to your root level /jobs folder
5) Visit "Dashboard->Automated Jobs" and click on 'Install' button next to this new Job (below the existing jobs)
6) Once it installs, click the 'Run' button.
Hope that helps
I followed your instructions and installed the new job. It works fine.
Unfortunately my problem persists: all files "sess_" in the "tmp" folder have permissions setted on 0600 (adfrw) by default.
So, the new job doesn't clean the folder. I always have to set the permissions on 777 manually, and then I'm unable to delete the files via ftp.
Any suggestion to solve my problem would be appreciated.
Thank you very much
For example, you could try the code below. It is the same code as before with the addition of a chmod command right before unlinking of the file.
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); /* Install Copy this file to /jobs Dashboard > System & Settings > Automated Jobs Install "Clean Temp Sessions" Automate the job to your liking */ class CleanTempSessions extends Job { public function getJobName() { return t('Clean Temp Sessions'); } public function getJobDescription() { return t('Cleans up PHP sess files from /files/tmp that are older than one day.');
I have not tested the above code so it may need further refinement by someone actively working with concrete5 (since I am no longer).
http://www.concrete5.org/marketplace/addons/enlil-sess-files-job/...
Until a "Job" is included in the optimization section to deal with the clearing out of the tmp folder,
You can simply delete the tmp folder because it will be re-created automatically as a new folder to hold the latest session file,
Not ideal but for the moment a quicker solution than deleting the individual sess files.