What's the best way to clear session files for a cherrypy app on RHEL 6 without clearing active sessions?

StackOverflow https://stackoverflow.com/questions/18320476

  •  25-06-2022
  •  | 
  •  

What's the best way to clear session files for a cherrypy app on RHEL 6.3 without clearing active sessions? Can I run a cron job that clears files where the last modified is greater than 15 days old?

I've tried executing this command...

find /path/to/files* -mtime +5 -exec rm {} \;

from this site

But it doesn't remove any files modified at least 5 days ago. Any help is appreciated.

有帮助吗?

解决方案

The sessions in cherrypy are expired and removed given the parameters of the session:

  • timeout: specify the minutes of inactivity to mark it as expired.
  • clean_freq: specify the frequency of the session cleaning in minutes

For example to dispatch a thread to delete the files each 3 minutes and a timeout of 5 minutes then just configure the session like this:

{'tools.sessions.timeout': 5,
 'tools.sessions.clean_freq': 3}

For more information on the properties of the session check out the official documentation.

But if you are looking to execute the cleaning by a cronjob why not just specify +4 instead of +5 to include the 5 on the date range, like:

find /path/to/files* -mtime +4 -exec rm {} \;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top