Is there any Python wrapper around cron?
Asked Answered
T

1

6

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 ?

Teri answered 26/2, 2010 at 17:11 Comment(3)
Similar post for reference #373835Poulson
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?Elwood
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?Kwon
J
12

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()
Joinder answered 27/2, 2010 at 20:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.