👋🏾 Looking to join our SuiteCRM Community Working Group? 💌 Open invitation throughout January. Check out all the details here 👈

How to cleanup session files

I have more than 10K zero byte files in my session folder. It seems they are created every second or so.
Any idea why these are being created? Is there something that I need to set to cleanup session files?


Search the web for this as a PHP issue, not a SuiteCRM issue.

You might have permissions issues and the files can’t be written to. Or maybe it now has so many files that you ran out of disk space, or inodes. Cleaning it once might solve you problem for good. (just maybe)

Upgrading PHP and web server might also help

@pgr, the problem is not a disk space issue at this time. All of my packages on the server are up to date. The permissions of the session folder and files are 775 / www-data:www-data.

Since this problem only started after I enabled the cron.php task, I looked into the scheduler process. What I have found is that cron.php is creating a session id only when these four schedules are ran:

Process Workflow Tasks
Check Inbound Mailboxes
Run Email Reminder Notifications
Run Report Generation Scheduled Tasks

Enabling any other schedule does not create the session file.

Still trying to figure out why these schedules are doing this.


Which user is your cron job running under?

Who owns the session folder? What are the exact permissions on that folder (the folder itself, not just the files in it). Please include everything, SetGID, SetUID, etc

ls -al session_folder

Yea, No problem…

total 936
drwxrwxr-x  2 www-data www-data 802816 Jan 14 11:44 .
drwxr-xr-x 21 www-data www-data  20480 Jan 14 10:01 ..
-rw-------  1 www-data www-data  77670 Jan 14 11:44 sess_cmr5d2hi2q4iv51rhf4rhak17h
-rw-------  1 www-data www-data  56852 Jan 14 11:41 sess_l1r6ou9bv672tit985nso91qth
-rw-------  1 www-data www-data      0 Jan 14 11:44 sess_mmg04boik1op7fsmeqbl0eham1

And the conjob is running under which user?

See explanations about the multiple crontabs here, if you need them:

Sorry I left that off, the crontab tasks are under www-data user.

root@dash-dev:/var/www/demo-SuiteCRM-7.11.15/session# crontab -u www-data -l

          •  cd /var/www/demo-SuiteCRM-7.11.15; php -f cron.php > /dev/null 2>&1

So I’ve run out of permissions issues to explore… I think your set up should work.

So falling back to your hypothesis that somehow the sessions aren’t getting deleted because the code isn’t finishing - can you get any further clues about this? Have you been looking at the php_errors.log? And suitecrm.log, of course?