Skip to main content

A simple Python Cron Expression lib

Project description

Python Cron Expression

PyPI version Coverage GitHub version

Introduction

Introducing PyCronExpression – a user-friendly Python library for crafting Cron job expressions effortlessly. With this tool, users can create Cron job expressions by simply passing a timestamp or datetime object. Say goodbye to the complexities of writing Cron expressions and embrace a more convenient way to manage scheduled tasks on Linux or AWS platforms.

Quickstart

Installation

Install from pypi:

pip install PyCronExpression
Feature List
Name status
Timestamp or datetime object done
Minute done
Hourly done
Daily Done
Weekly done

Example

Timestamp or datetime object

from datetime import datetime
from py_cron_expression import CronJobExpression
cron_job = CronJobExpression()

timestamp = int(datetime.now().timestamp())
res = cron_job.cron_expression(time=timestamp)
print(res)
# Output 
# 10 55 13 2 5 ? 2020

# If you want to remove second from in your cron job expression. 
# Then you need to add cancel='second'
# example
cron_job.cron_expression(time=timestamp, cancel='second')
# Output 
# 55 13 2 5 ? 2020

To learn more Documentation.

Changelog

See Changelog

License

MIT

Changelog

All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog. This project adheres to Semantic Versioning.

1.0.1 - 2023-10-28

Update

  • Update docs

1.0.0 - 2023-10-28

Add

  • Add weekly expression

0.1.0 - 2020-05-28

Fixed

  • Tuple comprehension in validations

0.1.1 - 2020-05-28

Fixed

  • Fixed broken coverage svg

Project details


Download files

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

Source Distribution

PyCronExpression-1.0.1.tar.gz (6.7 kB view hashes)

Uploaded Source

Built Distribution

PyCronExpression-1.0.1-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

Supported by

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