Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Cron Job to auto clean Magento Session files to save inodes

Discussion in 'Workarounds and Optimization' started by Logesh K, Apr 29, 2019.

Tags:
  1. Logesh K

    Logesh K Member

    Joined:
    Jun 25, 2015
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Namakkal, TamilNadu, India
    cPanel Access Level:
    Root Administrator
    Is it good to add the below code in /var/spool/cron/root to cleanup the Magento Session files regularly?

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

    Thanks
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,877
    Likes Received:
    482
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Logesh K

    Logesh K Member

    Joined:
    Jun 25, 2015
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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 {} \;
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice