You can but you can also modify expire_sessions.py

EXPIRATION_MINUTES=60
import os, time, stat
for app in ['admin','init','examples','welcome']: # add yours
    path=os.path.join(request.folder,'..',app,'sessions')
    if not os.path.exists(path):
       os.mkdir(path)
    now=time.time()
    for file in os.listdir(path):
        filename=os.path.join(path,file)
        t=os.stat(filename)[stat.ST_MTIME]
        if os.path.isfile(filename) and now-t>EXPIRATION_MINUTES*60 \
          and file.startswith(('1','2','3','4','5','6','7','8','9')):
          os.unlink(filename)

so that one expire_sessions.py does it for all your apps.
On May 19, 5:21 am, annet <annet.verm...@gmail.com> wrote:
> Massimo,
>
> Emil just tried running the following command on my account:
>
> python2.5 /home/fitwise/webapps/customweb2py/web2py/web2py.py  -S
> admin -R applications/admin/cron/expire_sessions.py
>
> This was successfully executed, and the output was:
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2010
> Version 1.76.5 (2010-03-11 15:19:08)
> Database drivers available: SQLite3, MySQL, PostgreSQL
>
> I verified that this actually cleaned up my sessions. It did in admin,
> not in init, b2b etc. Would it be possible to copy the
> expire_sessions.py to every single application's cron directory and
> set this command as a cron by editing my crontab (crontab -e):
>
> 10 * * * * /usr/local/bin/python2.5 /home/fitwise/webapps/customweb2py/
> web2py/web2py.py  -S init -R applications/init/cron/expire_sessions.py
>
> According to Emil:
>
> Applications do not really have crontabs. They may have some built-in
> feature which makes them work similar to crontab, but it is a
> completely separate system than your "real" crontab (the one you see
> when you runt 'crontab -l').
>
> By the way, the Web2py installation that I have is running behind
> Apache + mod_wsgi.
>
> Kind regards,
>
> Annet.

Reply via email to