crontab


Namecrontab JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/josiahcarlson/parse-crontab
SummaryParse and use crontab schedules in Python
upload_time2023-04-04 01:44:03
maintainerNone
docs_urlNone
authorJosiah Carlson
requires_pythonNone
licenseGNU LGPL v2.1
keywords
VCS
bugtrack_url
requirements python-dateutil pytz
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
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
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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/josiahcarlson/parse-crontab",
    "name": "crontab",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Josiah Carlson",
    "author_email": "josiah.carlson@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ae/13/696cac391e97fa47ec7323936838a540a610894a1d516a6b0cefbb1e495b/crontab-1.0.1.tar.gz",
    "platform": null,
    "description": "\nCopyright 2011-2021 Josiah Carlson\n\nReleased under the LGPL license version 2.1 and version 3 (you can choose\nwhich you'd like to be bound under).\n\nDescription\n===========\n\nThis package intends to offer a method of parsing crontab schedule entries and\ndetermining when an item should next be run. More specifically, it calculates\na delay in seconds from when the .next() method is called to when the item\nshould next be executed.\n\nComparing the below chart to http://en.wikipedia.org/wiki/Cron#CRON_expression\nyou will note that W and # symbols are not supported.\n\n============= =========== ================= ============== ===========================\nField Name    Mandatory   Allowed Values    Default Value  Allowed Special Characters\n============= =========== ================= ============== ===========================\nSeconds       No          0-59              0              \\* / , -\nMinutes       Yes         0-59              N/A            \\* / , -\nHours         Yes         0-23              N/A            \\* / , -\nDay of month  Yes         1-31              N/A            \\* / , - ? L\nMonth         Yes         1-12 or JAN-DEC   N/A            \\* / , -\nDay of week   Yes         0-6 or SUN-SAT    N/A            \\* / , - ? L\nYear          No          1970-2099         *              \\* / , -\n============= =========== ================= ============== ===========================\n\nIf your cron entry has 5 values, minutes-day of week are used, default seconds\nis and default year is appended. If your cron entry has 6 values, minutes-year\nare used, and default seconds are prepended.\n\nAs such, only 5-7 value crontab entries are accepted (and mangled to 7 values,\nas necessary).\n\n\nSample individual crontab fields\n================================\n\nExamples of supported entries are as follows::\n\n    *\n    */5\n    7/8\n    3-25/7\n    3,7,9\n    0-10,30-40/5\n\nFor month or day of week entries, 3 letter abbreviations of the month or day\ncan be used to the left of any optional / where a number could be used.\n\nFor days of the week::\n\n    mon-fri\n    sun-thu/2\n\nFor month::\n\n    apr-jul\n    mar-sep/3\n\nInstallation\n============\n\n::\n\n    pip install crontab\n\n\nExample uses\n============\n\n::\n\n    >>> from crontab import CronTab\n    >>> from datetime import datetime\n    >>> # define the crontab for 25 minutes past the hour every hour\n    ... entry = CronTab('25 * * * *')\n    >>> # find the delay from when this was run (around 11:13AM)\n    ... entry.next()\n    720.81637899999998\n    >>> # find the delay from when it was last scheduled\n    ... entry.next(datetime(2011, 7, 17, 11, 25))\n    3600.0\n\n\n\n\nNotes\n=====\n\nAt most one of 'day of week' or 'day of month' can be a value other than '?'\nor '*'. We violate spec here and allow '*' to be an alias for '?', in the case\nwhere one of those values is specified (seeing as some platforms don't support\n'?').\n\nThis module also supports the convenient aliases::\n\n    @yearly\n    @annually\n    @monthly\n    @weekly\n    @daily\n    @hourly\n\nExample full crontab entries and their meanings::\n\n    30 */2 * * * -> 30 minutes past the hour every 2 hours\n    15,45 23 * * * -> 11:15PM and 11:45PM every day\n    0 1 ? * SUN -> 1AM every Sunday\n    0 1 * * SUN -> 1AM every Sunday (same as above)\n    0 0 1 jan/2 * 2011-2013 ->\n        midnight on January 1, 2011 and the first of every odd month until\n        the end of 2013\n    24 7 L * * -> 7:24 AM on the last day of every month\n    24 7 * * L5 -> 7:24 AM on the last friday of every month\n    24 7 * * Lwed-fri ->\n        7:24 AM on the last wednesday, thursday, and friday of every month\n",
    "bugtrack_url": null,
    "license": "GNU LGPL v2.1",
    "summary": "Parse and use crontab schedules in Python",
    "version": "1.0.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ae13696cac391e97fa47ec7323936838a540a610894a1d516a6b0cefbb1e495b",
                "md5": "5fd66f1f7e6527be1fcf81c582ce6ad6",
                "sha256": "89477e3f93c81365e738d5ee2659509e6373bb2846de13922663e79aa74c6b91"
            },
            "downloads": -1,
            "filename": "crontab-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5fd66f1f7e6527be1fcf81c582ce6ad6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 19616,
            "upload_time": "2023-04-04T01:44:03",
            "upload_time_iso_8601": "2023-04-04T01:44:03.611134Z",
            "url": "https://files.pythonhosted.org/packages/ae/13/696cac391e97fa47ec7323936838a540a610894a1d516a6b0cefbb1e495b/crontab-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-04 01:44:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "josiahcarlson",
    "github_project": "parse-crontab",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "python-dateutil",
            "specs": []
        },
        {
            "name": "pytz",
            "specs": []
        }
    ],
    "lcname": "crontab"
}
        
Elapsed time: 0.12283s