Registry / workflow / crontab

crontab

JSON →
library1.0.5pypypi✓ verified 24d ago

The `crontab` library (from the `josiahcarlson/parse-crontab` project) is a Python package designed to parse crontab schedule entries and determine the next execution time. It calculates delays in seconds until a scheduled event. The current version is 1.0.5, with sporadic but active development and releases.

pip install crontab
INSTALL
IMPORT
SIG · CRONTAB
C
crontab
workflowpythonv1.0.5
Install
3.0s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.5 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.0s · import 0.008s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

CronTab
from crontab import CronTab
from python_crontab import CronTab
This library (pypi-slug: `crontab`, github: `josiahcarlson/parse-crontab`) is distinct from `python-crontab` (pypi-slug: `python-crontab`), which has similar import paths but different functionality (parsing vs. system crontab management).

This example demonstrates how to parse a cron string and calculate its next execution time using the `CronTab` class. It uses `datetime` and `timedelta` to convert the returned delay in seconds into an absolute datetime object.

from crontab import CronTab from datetime import datetime # Define a crontab entry for 25 minutes past the hour, every hour entry = CronTab('25 * * * *') # Get the next scheduled execution time from now now = datetime.now() next_run_time = now + timedelta(seconds=entry.next(now)) print(f"Current time: {now}") print(f"Next run for '25 * * * *' will be at: {next_run_time}") # Example with a specific start time some_past_time = datetime(2023, 1, 1, 10, 15, 0) next_from_past = some_past_time + timedelta(seconds=entry.next(some_past_time)) print(f"Next run from {some_past_time} would be at: {next_from_past}")
Debug
Known issues
gotchaPotential confusion with `python-crontab` library. The `crontab` (PyPI slug) library, backed by `josiahcarlson/parse-crontab` on GitHub, focuses on parsing cron expressions and calculating next run times. Another popular library, `python-crontab` (PyPI slug), provides similar `from crontab import CronTab` imports but is designed for managing system crontab entries. Ensure you've installed and are importing the library that matches your intended use (parsing vs. system management).
fix
Verify the library's functionality on its PyPI page or GitHub repository, and explicitly install `crontab` for parsing or `python-crontab` for system management if that's what you need.
affects: All versions
gotchaUnsupported cron expression symbols and field limits. This library (`crontab` by josiahcarlson) explicitly states that 'W' and '#' symbols are not supported. It also only accepts 5-7 value crontab entries, which are internally 'mangled' to 7 values (seconds-year) as necessary.
fix
Avoid using unsupported symbols. Ensure your cron expressions adhere to the 5-7 field format compatible with standard Unix cron, noting the library's specific interpretation.
affects: All versions
gotchaScripts executed by system cron jobs often fail due to differences in the execution environment (e.g., `PATH`, current working directory, user permissions, virtual environment activation) compared to manual execution. This is a general `cron` issue but critical for scripts scheduled based on this library's output.
fix
Use absolute paths for scripts, commands, and any files accessed. Explicitly set `PATH` and activate virtual environments within the cron job definition. Redirect stdout/stderr to log files for debugging.
affects: N/A (system-level issue)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'crontab'
The `josiahcarlson/parse-crontab` library, which is typically imported as `crontab`, is not installed in the current Python environment, or there is a Python path issue preventing its discovery.
fix
Install the library using pip: `pip install parse-crontab`
TypeError: __init__() missing 1 required positional argument: 'crontab'
The `CronTab` class from the `josiahcarlson/parse-crontab` library was instantiated without providing the mandatory crontab expression string as an argument.
fix
Instantiate `CronTab` with a valid crontab string, for example: `from crontab import CronTab; cron = CronTab('* * * * *')`
AttributeError: module 'crontab' has no attribute 'CronSlices'
This error typically occurs when a developer has installed `josiahcarlson/parse-crontab` but is attempting to use `CronSlices`, an attribute or class that belongs to a different `crontab`-related library (specifically `python-crontab`).
fix
If `CronSlices` functionality is desired, install and use the `python-crontab` library (`pip install python-crontab`). If the intention was to use `josiahcarlson/parse-crontab`, revise the code to use its `CronTab` class and its available methods.
ValueError: Invalid crontab expression (or similar ValueError message)
The crontab expression string provided to the `CronTab()` constructor contains invalid syntax, unsupported symbols (such as 'W' or '#'), an incorrect number of fields (the library expects 5 to 7 fields), or values outside the valid range for a specific field (e.g., a minute value greater than 59).
fix
Correct the crontab expression to comply with the supported syntax and value ranges of the `josiahcarlson/parse-crontab` library. Consult the library's documentation for valid formats.
Upgrade
Version history
1.0.5latest on PyPI · released Jul 9, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources
crontab — pip install crontab · libregistry