Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any Python wrapper around cron?

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 ?

like image 266
e-satis Avatar asked Feb 26 '10 17:02

e-satis


People also ask

Can I run Python script from cron?

The simplest way to do automation with Python is by using crontab (cron) on Mac or Task Scheduler on Windows. In this guide, you will learn how to use crontab run your Python scripts automatically. To know more, follow the rest of the tutorial below.

What is Cronwrap?

cronwrap 1.4A cron job wrapper that wraps jobs and enables better error reporting and command timeouts.

How do I know if a cron job ran successfully in Linux?

Using the grep command, you can view the log to see the last time when the specific script in the cron job was executed. If the cron job does not produce a visible output, then you would need to check to see if the cron job has actually taken place.


1 Answers

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()
like image 188
jfs Avatar answered Oct 21 '22 16:10

jfs