Forums | Mahara Community

Support /
Pruning session files


anonymous profile picture
Account deleted
Posts: 2

29 May 2014, 0:32

Everytime cron.php is run a new session file is created.  I don't see any being deleted.  I now have many thousands of these things.  

Why do I get these files and how can I either stop them being created or prune them to a sensible number.

Thanks

 

 

Aaron Wells's profile picture
Posts: 896

29 May 2014, 12:18

Hi Dick,

Thanks for the question! It turns out this is a bug in Mahara. Under normal circumstances (on Ubuntu and debian at least) PHP session files get deleted by a cron job on the server which is installed as part of the PHP package. But Mahara stores its session files in its own custom location, rather than in the default PHP location, and so the server cron job doesn't find them.

I've filed a bug about it here: https://bugs.launchpad.net/mahara/+bug/1324316

Until we fix this, there are 2 main workarounds:

1. You can clear the session files manually. If you go your site's Administration page, and click the "Close site" button, it will delete all session files except for the one for admin user's current session. You'll then need to reopen the site to let people log in. The downside to this is it will log out anyone currently logged into the site (that's the purpose of the feature). So you'd want to do this outside of peak usage hours.

2. You can set up a cron job on your server that locates and deletes Mahara session files that are too old. It should look something like the one used by Ubuntu for this purpose:

01,31 * * * * root find /path/to/your/dataroot/sessions -type f -cmin 1440 ! -execdir fuser -s {} 2>/dev/null \; -delete

Cheers,

Aaron

anonymous profile picture
Account deleted
Posts: 2

30 May 2014, 2:28

Aaron,

 

Thanks, that''s useful.  For future reference on the cron line it should be -cmin +1440 otherwise it doesn't find old files.

 

Cheers

 

Aaron Wells's profile picture
Posts: 896

07 July 2014, 15:35

Hi again Dick,

On further investigation, it turns out that the standard Mahara cron task should be deleting those session files. There is a Mahara cron task, "auth_remove_old_session_files", which runs daily and should delete session files that are more than 3 days old.

So I'm not sure why it's not removing them in your case. You might want to check your Mahara cron log files and see whether the auth_remove_old_session_files task is running. You could also check the file permissions on the session files. Perhaps the user you're running cron as, doesn't have permission to remove them.

Cheers,

Aaron

4 results