Sunday, April 20, 2008

clear session files - Ruby

Session is important for web application as track user. Session grow likely same as log files. This will cause memory overhead. We can clear session using Linux crontab command.

This will remove 300 minutes old session files by every day 00:10 hrs.

Place this command in the crontab file in the /usr/bin/ directroy.

Can edit the crontab file using following command.

crontab -e

* * * * * find absolute_path -name 'sess.*' -amin +300 -exec rm -rf {} \;
Explanation:
10 0 * * * find /home/tmp -name 'ruby_sess.*' -amin +300 -exec rm -rf {} \;

find - find the file that start with the name sess.

min +300
- find the session file with 300 minutes old

exec rm -rf - execute the command remove the files which is 300 minutes old.

0 comments:

Post a Comment