cancel
Showing results for 
Search instead for 
Did you mean: 

Cron for Automatically Deleteing Session Files

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Cron for Automatically Deleteing Session Files

Hi,

 

I'm having a buildup of session files, and rather than manually deleting them, I would like to have them be automatically deleted through the use of a Cron. Is this possible?

 

Many Thanks.

3 REPLIES 3

Re: Cron for Automatically Deleteing Session Files

Yes you can put those file location in cron of your server and run rm -rf command using crontab.

 

 use the crontab -e option to edit your crontab jobs and add below lines in it.

 

 

* * * * *  find  /path/to/*.log -mtime +7 -exec rm -f {} \; 

 

Where you need to give path of your session files and if you want to remove all files just remove .log from the end.

 

For more reference refer this link - https://stackoverflow.com/questions/22462716/remove-log-files-using-cron-job

if issue solved,Click Kudos & Accept as Solution

Re: Cron for Automatically Deleteing Session Files

Hi,

 

So in my case I would like it to be deleted every 2 hours, so:

 

* 2 * * *  find  /path/to/*

 

Re: Cron for Automatically Deleteing Session Files

@I_K22 - In your case below is the command you need to put in crontab.

 

* 2 * * *  find  /path/to/* -mtime +7 -exec rm -f {} \; 

 

Note : Its always good to take a backup first when we are doing(delete) something new , so here i would suggest take a backup first then and try.

if issue solved,Click Kudos & Accept as Solution