a small crontab deploying package for python
A small tool for deploying crontab jobs into a unix-like system, eg. Linux/Mac from python.
cronpi makes jobs more human readable and works on both 2.X and 3.X version.
pip install cronpi
cronpi has following functions
|1.||run_by_date||job that runs just once by setting date in format YYYY-MM-DD HH:mm|
|2.||run_every_day||job that runs every day at given time HH:mm|
|3.||run_every_week||job that runs every week at the given time of given weekdays|
|4.||run_every_month||job that runs every month at the given time of given days of a month|
|5.||run_every_year||job that runs at the given time of given days of given months|
|6.||run_custom||command will be exactly similar to single line which we write during "crontab -e"|
Each functions take two parameters
<command to execute>, <isOverwrite=bool>?
|command||string||This command will be executed as scheduled|
|isOverwrite||bool||It is optional and default value is false, which means cronpi will always insert new job|
cronpi will always install a new cron job if only command is passed as parameter or isOverwrite is set to False. If command passed as first parameter already exists in cronjon and "isOverwrite=True" is passed as second parameter ,then it will update the time of running the job instead of adding new job.
Use Case 1 - Run once
- Run a job at 20th october 2020 at 5:30PM
Use Case 2 - Run every day
- Run a job daily at 5:30PM
Use Case 3 - Run every week
- Run a job at every sunday at 5:30PM
- Run a job at every saturday and sunday at 5:30PM
cronpi.run_every_week("/some/command").on(["sat", "sun"], time="5:30PM")
Use Case 4 - Run every month
- Run a job at every 10th of a month at 5:30PM
- Run a job at every 10th and 20th of a month at 5:30PM
Use Case 5 - Run every year
- Run a job at every 10th january at 5:30am
cronpi.run_every_year("/some/command").on("january", day=10, time="5:30am")
- Run a job at every 10th of january, april and october at 5:30AM
cronpi.run_every_year("/some/command").on(["jan", "oct"], day=10, time="5:30")
Use Case 6 - run like crontab
Add a job to crontab by passing the command that we input to "crontab -e" command.
- Run a job that runs at every minute
cronpi.run_custom("* * * * * /some/command")
# ┌───────────── minute (0 - 59) # │ ┌───────────── hour (0 - 23) # │ │ ┌───────────── day of the month (1 - 31) # │ │ │ ┌───────────── month (1 - 12) # │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday; # │ │ │ │ │ 7 is also Sunday on some systems) # │ │ │ │ │ # │ │ │ │ │ # * * * * * command to execut
Helper Function - Get list of current jobs
cronpi has a helper function named "get_job_list" which will retrive the the job items in list.
Nov 12th, 2019 (firstname.lastname@example.org)
- restructured the library format so that it is more human readable.
cronpi.run_every_month("/some/command") .on([10,20], time="1:30AM")
Nov 7th, 2019 (email@example.com)
- released first version
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size cronpi-2.0.0-py3-none-any.whl (10.4 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size cronpi-2.0.0.tar.gz (7.9 kB)||File type Source||Python version None||Upload date||Hashes View hashes|