Cron Job to auto clean Magento Session files to save inodes

Logesh K

Member
Jun 25, 2015
11
0
1
Namakkal, TamilNadu, India
cPanel Access Level
Root Administrator
@Infopro Thanks for your reply. But since I am selling Shared Hosting on my servers, I won't be able to tuneup each Magento installation and I want to setup a Cron to delete the files.

So can you please tell me how about my code? Will it work and safe ?

Code:
0 0 * * * find /tmp -name 'sess*' -mtime +1 -exec rm -v {} \;
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello @Logesh K,

Can you check if the /usr/local/cpanel/scripts/clean_user_php_sessions script is cleaning up the older session files? We document how to use this script on the link below:

The clean_user_php_sessions Script - Version 78 Documentation - cPanel Documentation

Let me know if you notice any errors or if the script doesn't clean the old session files (it's setup to run daily as a root cron job, so it should remove them from the appropriate directory automatically).

For more information about where PHP session files are stored by default, read our MultiPHP INI Editor for WHM documentation.

Thank you.