hartwork / pytocron

Container cron with seconds resolution

Home Page:https://pypi.org/project/pytocron/

Repository from Github https://github.comhartwork/pytocronRepository from Github https://github.comhartwork/pytocron

pre-commit Run the test suite

pytocron

pytocron is a cron implementation targeting containers, written in Python, with seconds and year resolution, native support for Healthchecks.io and >90% test coverage. It is licensed under GNU Affero General Public License v3.0 or later and is meant to remain simple and maintainable.

One particular prime use case is to feed uptime monitoring. For example, here is how I monitor availability of my blog:

# hc-ping: https://hc-ping.com/00000000-0000-0000-0000-000000000000
*/30 * * * * * * wget -qO- -T2 https://blog.hartwork.org/ | grep -qF 'Hartwork Blog'

This would make pytocron check the blog for availability every 30 seconds and ping Healthchecks.io with the resulting exit code because of the # hc-ping: <URL> comment line.

Regarding name "pytocron": It was inspired by the term pytosquatting and it had no search results on Google.

If you like pytocron, please support it with a star!

Installation

# pip3 install pytocron

or

# pipx install pytocron

Usage

# pytocron --help
usage:
  pytocron [OPTIONS] CRONTAB
  pytocron --help
  pytocron --version

Container cron with seconds resolution

positional arguments:
  CRONTAB               Path to crontab file

options:
  -h, --help            show this help message and exit
  --log-level {DEBUG,ERROR,INFO}
                        Logging level (default: INFO)
  --pretend             Do not actually run commands (default: do run commands)
  --version             show program's version number and exit

environment variables:
  NO_COLOR              Disable use of color (default: auto-detect)
  SENTRY_DSN            Sentry [d]ata [s]ource [n]ame URL
  SENTRY_ENVIRONMENT    Sentry Environment (default: "production")
  SENTRY_RELEASE        Version or Git SHA1 to use with Sentry

Software libre licensed under AGPL v3 or later.
Brought to you by Sebastian Pipping <sebastian@pipping.org>.

Please report bugs at https://github.com/hartwork/pytocron/issues — thank you!
# pytocron --log-level ERROR <(echo '*/2 * * * * * * LC_TIME=C date')  # syntax needs Bash
Thu May 15 02:36:06 CEST 2025
Thu May 15 02:36:08 CEST 2025
Thu May 15 02:36:10 CEST 2025
^C

Comparison with other crons

  pytocron Supercronic Vixie Cron
Written in Python Go C
Container support      
∟ Targets containers containers non-container systems
∟ Environment variables kept kept ?
∟ Multi-user mode
∟ Logging target stdout, stderr stdout, stderr syslog or log file
∟ Log rotation support
∟ Command shell bash -e -u /bin/sh /bin/sh
∟ Daemonization
∟ Crontab reloading
Integrations      
∟ Support for Healthchecks.io
∟ Support for Sentry
Crontab syntax      
∟ Seconds and year resolution ✔ (forced) ✔ (optional)
∟ Implementation croniter cronexpr custom
Exceeded job runtime handling auto-kill overlapping or skips ?
Handling of daylight saving time skips, duplicates ? ?
Reaction to NTP adjustments none ? ?
Signal handling      
SIGHUP shutdown shutdown log file reopen
SIGUSR2 shutdown crontab file reload shutdown

Contributing

Prior to opening pull requests, please create an issue to discuss the matter first. Thank you!

Security

If you believe to have found a security issue within pytocron, please reach out via e-mail. Thank you!

Support

Please report any bugs that you find.

Like this tool? Support it with a star!

About

Container cron with seconds resolution

https://pypi.org/project/pytocron/

License:GNU Affero General Public License v3.0


Languages

Language:Python 100.0%