5

I'm looking for a wrapper around cron.

I've stumbled upon PyCron but it's a Python implementation, not a wrapper.

Do you know any good cron Python wrapper ?

If not, did you test PyCron, and what can you tell about it ?

//EDIT (As an answer to comment asking for more details):

I am looking for something to set a cron job in a pythonic way such as:

>>> job = CronJob(call_back)
>>> job.schedule(datetime, repeat)
>>> job.schedule(datetime2, repeat2)

And I could edit the currents job this way:

>>> jobs = loadFromCron()
>>> jobs[0].shedule().schedule(datetime, repeat)
>>> print(jobs[0])
<CronJob object - "call_back" at 2009-11-01>

Ideally, that would write and read from "crontab" under linux and use "planified tasks" under windows.

I may used the wrong terminology, is it more accurate to talk about a cron Python API ?

Bite code
  • 578,959
  • 113
  • 301
  • 329
  • 1
    Similar post for reference http://stackoverflow.com/questions/373335/suggestions-for-a-cron-like-scheduler-in-python – Martin Feb 26 '10 at 17:14
  • 4
    I think you probably have to clarify your question. The term cron is mostly used in context of the linux cron job system, which enables you to run commands in certain time intervals. I cannot think of a wrapper around this functionality. Do you want to run a python script on a certain time interval? Or do you want to have a python interface to add cron jobs to your cron tab more easily? – FlorianH Feb 26 '10 at 17:14
  • 1
    cron wakes up, checks the crontabs, and starts processes. It's a core feature of Linux. What would a "wrapper" around this do? cron can already start processes that run Python. cron is always running. What more is there? – S.Lott Feb 26 '10 at 18:28

1 Answers1

11

python-crontab allows you to read and write user crontabs via python programs.

from crontab import CronTab

tab = CronTab()
cron = tab.new(command='/foo/bar')
cron.every_reboot()
tab.write()
jfs
  • 399,953
  • 195
  • 994
  • 1,670