Registry / devops / local-crontab

local-crontab

JSON →
library0.3.0pypypi✓ verified 85d ago

local-crontab is a Python wheel and command line utility designed to convert a crontab, defined in a local timezone, into a set of UTC crontabs. This conversion often results in multiple UTC crontabs due to the complexities of Daylight Saving Time (DST). The project is based on an earlier `local-crontab` by UnitedIncome, incorporating bug fixes and extending functionality to convert specific hour and day parts. As of version 0.3.0, released in July 2021, the library appears to be in a maintenance status with infrequent updates.

pip install local-crontab
INSTALL
IMPORT
SIG · LOCAL-CRONTAB
L
local-crontab
devopspythonv0.3.0
Install
1.9s avg
Import
39ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.041s · 19.6MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.9s · import 0.037s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Converter
from local_crontab import Converter

Demonstrates how to instantiate the `Converter` class with a local crontab string and its timezone, then use the `convert()` method to get a list of corresponding UTC crontab strings.

from local_crontab import Converter # Example 1: Convert a crontab from 'America/New_York' to UTC # This will typically produce two UTC crontabs due to DST changes. converter_ny = Converter('0 10 * * *', 'America/New_York') utc_crontabs_ny = converter_ny.convert() print(f"Original (NY): 0 10 * * *") print(f"UTC conversions for 'America/New_York': {utc_crontabs_ny}") # Expected output similar to: ['0 15 * * *', '0 14 * * *'] (order may vary) # Example 2: Convert a crontab for 'Europe/Berlin' # Also likely to produce two UTC crontabs due to DST. converter_berlin = Converter('30 8 * * *', 'Europe/Berlin') utc_crontabs_berlin = converter_berlin.convert() print(f"\nOriginal (Berlin): 30 8 * * *") print(f"UTC conversions for 'Europe/Berlin': {utc_crontabs_berlin}") # Expected output similar to: ['30 7 * * *', '30 6 * * *'] (order may vary)
local-crontab --version
Debug
Known issues
gotchaThe library typically generates multiple UTC crontab entries for a single local crontab. This is by design, accounting for Daylight Saving Time (DST) changes throughout the year. Users expecting a single, fixed UTC equivalent might find this behavior unexpected.
fix
Understand that the output of `converter.convert()` is a list of crontab strings. Implement logic to select the appropriate UTC crontab based on the current date, or consider external 'dst check' mechanisms if only one active UTC schedule is required year-round.
affects: All versions
gotchaWhile the library allows converting crontab 'hour and day parts' to a single UTC equivalent, maintaining year-round accuracy through DST changes requires an *external* 'dst check' program. This external tool is not part of the `local-crontab` library.
fix
Be aware that the 'single UTC crontab' feature for hour/day parts is a partial solution. If full DST awareness and year-round accuracy are critical, an external mechanism to manage the active UTC schedule is necessary.
affects: All versions
gotchaThis `local-crontab` package is a fork and bug-fixed version of an older project by 'UnitedIncome'. While improvements are included, users familiar with or migrating from the original might encounter subtle behavioral differences or API changes not explicitly documented as breaking changes.
fix
If migrating from an older 'UnitedIncome' version, review the GitHub repository's commit history and source code for any unlisted changes. Thorough testing of existing workflows is recommended.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'local_crontab'
The `local-crontab` package was installed, but the import statement uses an incorrect module name or the package is not in Python's `sys.path`.
fix
Ensure the package is installed via `pip install local-crontab`. The correct import statement is `from local_crontab import Converter` (note the underscore in `local_crontab`).
TypeError: Converter() takes 2 positional arguments but 3 were given
The `Converter` class constructor was called with an incorrect number of arguments.
fix
The `Converter` class expects exactly two arguments: the crontab string and the local timezone string, e.g., `Converter('0 10 * * *', 'America/New_York')`.
pytz.exceptions.UnknownTimeZoneError: 'Invalid/Unknown' is not a valid timezone
An invalid or unrecognized timezone string was provided to the `Converter` class.
fix
Ensure the timezone string passed to `Converter` is a valid `pytz` timezone name (e.g., 'America/New_York', 'Europe/London'). Consult the `pytz` documentation for a list of supported timezones.
Upgrade
Version history
0.3.0latest on PyPI · released Jul 9, 2021
Audit
Dependencies
python-crontabrequiredRequired for parsing and manipulating cron strings.
pytzrequiredRequired for timezone calculations, especially for handling Daylight Saving Time.
tzlocalrequiredUsed for determining the local timezone.
Agent activity
20 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
local-crontab — pip install local-crontab · libregistry