If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

Here's how to access any crontab in your O.S. with the very useful Python module python-crontab (see the module documentation for command options and howtos). It's possible to read and write the crontab files from your web2py app.


1) Install the module with the package provided at pypi, or copy the module file in <app>/modules


2) In the controller (i.e. default.py), add the action to return the crontab list

def showcrontab():
    from crontab import CronTab
    return dict(mycrontab=CronTab())

3) In the view (i.e. default/showcrontab.html), you can present a list with all the tasks

{{for job in mycrontab:}}

That's all. Now you have access to the crontab tasks by accessing a web2py action in a web browser.


TODO: add an example to edit crontab files using form and table helpers


Note: reading and writing web2py crontab files should be straightforward too, since they are (supposedly) actual crontab files. Please let me know if it actually works with web2py crontabs also.

Comments (0)

Hosting graciously provided by:
Python Anywhere