Help - Millions of sess_ files in tmp folder
Permalink
Hello,
My 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
My 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
Thank's for the input, but indeed I suffer from the same problem. This should be added in the TODO list for the next release.
Check your php configuration.
http://ca.php.net/manual/en/session.configuration.php#ini.session.g...
http://ca.php.net/manual/en/session.configuration.php#ini.session.g...
I'm struggling with this, too. Trying to back up a site before upgrading from 5.6.0.2 to 5.6.1 and the /tmp/ directory is killing me. Unable to zip from the command line on my web server and deleting the /tmp/ directory in prep for zipping has taken 1:42 minutes so far (it's still "rm"-ing). I think its massive bloatiness might be the reason why backup cron jobs on this server haven't been completing.
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.)
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.)
Have you asked your host about it? Shouldn't their 'garbage clean-up' routines be expiring the sessions and deleting them.
Thanks for the direction, mhawke. I'll ping them and find out. :)
We have also this problem with 5.6.2.
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?
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?
Not sure, but maybe this helps too?
http://www.concrete5.org/marketplace/addons/cache-vac/...
http://www.concrete5.org/marketplace/addons/cache-vac/...
It seems to be a bug with Debian and Ubuntu.
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...
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 don't believe that add-on touches the /files/tmp folder.
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.
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.
One solution to this would also be to simply delete the session files through cron once a day, for example:
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).
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).
One of my favorite clients (msanderson) had a site with messy /files/tmp folder. Our solution was to create a concrete5 job to clean up any sess_ files older than a day.
Here is the job file "clean_temp_sessions.php" we created along with install instructions.
Posted with love in case anyone else finds it useful. ^_^
Cheers!
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.');
Viewing 15 lines of 34 lines. View entire code block.
Posted with love in case anyone else finds it useful. ^_^
Cheers!
Thanks, I was looking exactly for this! It works perfectly.
Sorry for the bad pun, but... great job :)
jordi
Sorry for the bad pun, but... great job :)
jordi
Great! A very useful job!
Hi ForestMist,
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
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
Perhaps I can help. This assumes you are running version 5.6.x.x.
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
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
Nice instructions mhawke. Thanks. :)
Hi mhawke, many thanks for your reply.
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
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
Usinghttp://php.net/function.chmod in the job to set the permissions on the file before removing it may help. Keyword, may.
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.
I have not tested the above code so it may need further refinement by someone actively working with concrete5 (since I am no longer).
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.');
Viewing 15 lines of 35 lines. View entire code block.
I have not tested the above code so it may need further refinement by someone actively working with concrete5 (since I am no longer).
Just what I was looking for! Took it one step further and put it in package form using forestmist's most recent code. @adwlabs, unzip it, place it in your root packages folder and install it through the dashboard. Haven't tested against any chmod quirks yet, but is working as expected in my environment. Any feedback to make it better is welcome and with forestmist's kindly ok, I'd be happy to push this to the marketplace as a free add-on for broader use. Enjoy. See Attached...
Please feel free to use the code for whatever you wish. :D
thanks to all. I think it was a server problem, because now the automatic process works fine. Many thanks
This is now available free in the marketplace!
http://www.concrete5.org/marketplace/addons/enlil-sess-files-job/...
http://www.concrete5.org/marketplace/addons/enlil-sess-files-job/...
Nice. More people will be able to use it as an installable package. Good job. :D
Just leave it there. Its part of the system files.
sure, until there's a million of them and your server crashes because theres no disk space left :|
Will this job work with 5.7?
No it is for 5.6
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.