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.
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
Hi,
So in my case I would like it to be deleted every 2 hours, so:
* 2 * * * find /path/to/*
@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.