Skip to main content

A package to run cron jobs(events)

Project description

Cron Events

This module provides a way to schedule recurring events using a cron-like syntax. Events can be scheduled to run at specific intervals or at specific times on specific days.

Table of Contents

Installation

pip install cronevents

Learn by Example

"""Cron-like event scheduling module.

This module provides a way to schedule recurring events using a cron-like syntax.
Events can be scheduled to run at specific intervals or at specific times on specific days.

Syntax:
    'every (`Weekday` or `n unit`) [@ hh[:mm[:ss]] ["am" or "pm"]]'

Examples:
    'every 2 days @ 10:00:00 pm'
    'every Monday @ 23'
    'every 5 seconds'

Note:
    Using '@' will run the event at least once a day.
"""

# Uncomment to register events to the event manager
# import os
# os.environ['REGISTER_CRON_EVENT'] = 'true'

from cronevents.event_manager import event


@event('every 31 seconds')
def test():
    """Write 'test' to a file and print it every 31 seconds."""
    with open('test.txt', 'a') as f:
        f.write('test\n')
    print('test')


@event('every 2 days 1 hours 23 minutes 2 seconds')
def test2():
    """Write 'test2' to a file and print 'test2' every 2 days, 1 hour, 23 minutes, and 2 seconds."""
    with open('test.txt', 'a') as f:
        f.write('test2\n')
    print('test2')


@event('every 1 days @ 2:00 pm')
def test3():
    """Write 'test3' to a file and print it daily at 2:00 PM."""
    with open('test.txt', 'a') as f:
        f.write('test3\n')
    print('test3')


@event('every Friday')
def test4():
    """Write 'test4' to a file and print it every Friday."""
    with open('test.txt', 'a') as f:
        f.write('test4\n')
    print('test4')


@event('every Tuesday @ 3:00')
def test5():
    """Write 'test5' to a file and print it every Tuesday at 3:00 AM."""
    with open('test.txt', 'a') as f:
        f.write('test5\n')
    print('test5')

License

  • MIT License

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cronevents-0.0.40a12.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cronevents-0.0.40a12-py3-none-any.whl (45.1 kB view details)

Uploaded Python 3

File details

Details for the file cronevents-0.0.40a12.tar.gz.

File metadata

  • Download URL: cronevents-0.0.40a12.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for cronevents-0.0.40a12.tar.gz
Algorithm Hash digest
SHA256 a9a33326d0496db28e25f6a46877c5b07767054bd388a18fb856b09eb8c86645
MD5 d603469014fa1cd4a5c29798251f0047
BLAKE2b-256 32990055f2a38e7234b4fd4108fa17cc3758e6860cd5ef61a5b04ed731ba8e50

See more details on using hashes here.

File details

Details for the file cronevents-0.0.40a12-py3-none-any.whl.

File metadata

  • Download URL: cronevents-0.0.40a12-py3-none-any.whl
  • Upload date:
  • Size: 45.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for cronevents-0.0.40a12-py3-none-any.whl
Algorithm Hash digest
SHA256 27594b72ae31b5a9cd179258264c8c08f8d0ea9d96447827616c2ce2fd0fcbe8
MD5 05be317a0b4703260ac2820e0a7a8c18
BLAKE2b-256 2ef05b51f6e5e7bfb24084f7a1f24b54d1c70f50008e1386ddf7dd96ba240f03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page