crontab

Parse and use crontab schedules in Python

https://github.com/josiahcarlson/parse-crontab

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 11 committers (9.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.5%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Parse and use crontab schedules in Python

Basic Info
  • Host: GitHub
  • Owner: josiahcarlson
  • License: lgpl-2.1
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 104 KB
Statistics
  • Stars: 332
  • Watchers: 14
  • Forks: 63
  • Open Issues: 3
  • Releases: 0
Created almost 15 years ago · Last pushed 12 months ago
Metadata Files
Readme Changelog Funding License

README.rst

Copyright 2011-2021 Josiah Carlson

Released under the LGPL license version 2.1 and version 3 (you can choose
which you'd like to be bound under).

Description
===========

This package intends to offer a method of parsing crontab schedule entries and
determining when an item should next be run. More specifically, it calculates
a delay in seconds from when the .next() method is called to when the item
should next be executed.

Comparing the below chart to http://en.wikipedia.org/wiki/Cron#CRON_expression
you will note that W and # symbols are not supported.

============= =========== ================= ============== ===========================
Field Name    Mandatory   Allowed Values    Default Value  Allowed Special Characters
============= =========== ================= ============== ===========================
Seconds       No          0-59              0              \* / , -
Minutes       Yes         0-59              N/A            \* / , -
Hours         Yes         0-23              N/A            \* / , -
Day of month  Yes         1-31              N/A            \* / , - ? L Z
Month         Yes         1-12 or JAN-DEC   N/A            \* / , -
Day of week   Yes         0-6 or SUN-SAT    N/A            \* / , - ? L
Year          No          1970-2099         *              \* / , -
============= =========== ================= ============== ===========================

If your cron entry has 5 values, minutes-day of week are used, default seconds
is and default year is appended. If your cron entry has 6 values, minutes-year
are used, and default seconds are prepended.

As such, only 5-7 value crontab entries are accepted (and mangled to 7 values,
as necessary).


Sample individual crontab fields
================================

Examples of supported entries are as follows::

    *
    */5
    7/8
    3-25/7
    3,7,9
    0-10,30-40/5

For month or day of week entries, 3 letter abbreviations of the month or day
can be used to the left of any optional / where a number could be used.

For days of the week::

    mon-fri
    sun-thu/2

For month::

    apr-jul
    mar-sep/3

Installation
============

::

    pip install crontab


Example uses
============

::

    >>> from crontab import CronTab
    >>> from datetime import datetime
    >>> # define the crontab for 25 minutes past the hour every hour
    ... entry = CronTab('25 * * * *')
    >>> # find the delay from when this was run (around 11:13AM)
    ... entry.next()
    720.81637899999998
    >>> # find the delay from when it was last scheduled
    ... entry.next(datetime(2011, 7, 17, 11, 25))
    3600.0




Notes
=====

At most one of 'day of week' or 'day of month' can be a value other than '?'
or '*'. We violate spec here and allow '*' to be an alias for '?', in the case
where one of those values is specified (seeing as some platforms don't support
'?').

This module also supports the convenient aliases::

    @yearly
    @annually
    @monthly
    @weekly
    @daily
    @hourly

Example full crontab entries and their meanings::

    30 */2 * * * -> 30 minutes past the hour every 2 hours
    15,45 23 * * * -> 11:15PM and 11:45PM every day
    0 1 ? * SUN -> 1AM every Sunday
    0 1 * * SUN -> 1AM every Sunday (same as above)
    0 0 1 jan/2 * 2011-2013 ->
        midnight on January 1, 2011 and the first of every odd month until
        the end of 2013
    24 7 L * * -> 7:24 AM on the last day of every month
    24 7 * * L5 -> 7:24 AM on the last friday of every month
    24 7 * * Lwed-fri ->
        7:24 AM on the last wednesday, thursday, and friday of every month
    0 8 L * * -> 8 AM on the last day of the month, every month
    0 8 Z0 * * -> 8 AM on the last day of the month, z0 is an alias for L
    0 8 Z1 * * -> 8 AM 1 day before the last day of the month, every month
    0 8 Z2 * * -> 8 AM 2 days before last day of the month, every month

Owner

  • Name: Josiah Carlson
  • Login: josiahcarlson
  • Kind: user
  • Location: Los Angeles, CA

Applied theoretical computer scientist turned systems architect / CTO for startups. Work contributions: @josiah-co / @josiah-im

GitHub Events

Total
  • Issues event: 2
  • Watch event: 8
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 4
  • Pull request event: 2
  • Fork event: 2
  • Create event: 2
Last Year
  • Issues event: 2
  • Watch event: 8
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 4
  • Pull request event: 2
  • Fork event: 2
  • Create event: 2

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 47
  • Total Committers: 11
  • Avg Commits per committer: 4.273
  • Development Distribution Score (DDS): 0.277
Past Year
  • Commits: 4
  • Committers: 3
  • Avg Commits per committer: 1.333
  • Development Distribution Score (DDS): 0.5
Top Committers
Name Email Commits
Josiah Carlson j****n@g****m 34
Graham Bell g****l@j****u 2
Josiah Carlson j****h@a****y 2
pyohei m****6@g****m 2
Jonathan Kamens j****k@q****m 1
JJ Wong j****5@u****m 1
zaraken n****v@g****m 1
Dave Gaeddert d****t@g****m 1
White A****e@h****m 1
pengweikang p****g@i****m 1
John Vandenberg j****b@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 32
  • Total pull requests: 13
  • Average time to close issues: 2 months
  • Average time to close pull requests: 4 months
  • Total issue authors: 30
  • Total pull request authors: 13
  • Average comments per issue: 2.56
  • Average comments per pull request: 2.31
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: 9 days
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • amelio-vazquez-reina (3)
  • iamthebot (1)
  • dreamalligator (1)
  • categulario (1)
  • hackfengJam (1)
  • sidahmed-malaoui (1)
  • camrdale (1)
  • shinokada (1)
  • rfyiamcool (1)
  • nickmaccarthy (1)
  • mgedmin (1)
  • ashvarma1982 (1)
  • isergey (1)
  • dsully (1)
  • danvk (1)
Pull Request Authors
  • davegaeddert (1)
  • pyohei (1)
  • jjwong0915 (1)
  • jayvdb (1)
  • pengwk (1)
  • markcox (1)
  • jikamens (1)
  • zaraken (1)
  • timfeirg (1)
  • avandever (1)
  • grahambell (1)
  • aleksandr-w (1)
  • li-mdubey (1)
Top Labels
Issue Labels
fixed (12) question (9) bug (8) not applicable (5) feature (2)
Pull Request Labels
fixed (1) feature (1) bugfix (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 930,401 last-month
  • Total docker downloads: 201,754,588
  • Total dependent packages: 38
    (may contain duplicates)
  • Total dependent repositories: 284
    (may contain duplicates)
  • Total versions: 36
  • Total maintainers: 1
pypi.org: crontab

Parse and use crontab schedules in Python

  • Versions: 28
  • Dependent Packages: 37
  • Dependent Repositories: 284
  • Downloads: 930,401 Last month
  • Docker Downloads: 201,754,588
Rankings
Dependent packages count: 0.4%
Docker downloads count: 0.4%
Downloads: 0.5%
Dependent repos count: 0.9%
Average: 1.9%
Stargazers count: 3.6%
Forks count: 5.4%
Maintainers (1)
Last synced: 10 months ago
conda-forge.org: crontab
  • Versions: 8
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Stargazers count: 20.2%
Forks count: 21.5%
Average: 26.1%
Dependent packages count: 28.8%
Dependent repos count: 34.0%
Last synced: 11 months ago

Dependencies

setup.py pypi
  • pytz *
requirements.txt pypi
  • python-dateutil *
  • pytz *
requirements_old.txt pypi
  • python-dateutil *
  • pytz *
pyproject.toml pypi