Run any Python script on a custom cron schedule with environment-based configuration and logging.
324
Run any Python script on a custom cron schedule with environment-based control and logging.
Pull command:
docker pull gurkiratm/python-cron:latest
This image runs any user-supplied Python script on a recurring schedule using cron, with parameters passed via environment variables. It installs dependencies at runtime and logs output to a configurable or timestamped file inside the container.
PYTHON_SCRIPT_PATHCRON_SCHEDULE (default: 0 9 * * *)LOG_FILE/app/.venvrequirements.txt via REQUIREMENTS_FILE (default: /app/requirements.txt)busybox crond running in foreground for clean logs| Variable | Required | Description |
|---|---|---|
PYTHON_SCRIPT_PATH | ā Yes | Full path to the Python script inside the container |
CRON_SCHEDULE | ā No | Cron format schedule (default: 0 9 * * *) |
LOG_FILE_PATH | ā No | Log file name (Default: /app/script_python_dYYYYMMDD_tHHMMSS.log) |
REQUIREMENTS_FILE | ā No | Path to requirements.txt (Default: /app/requirements.txt : empty) |
Mount your Python script and any inputs:
-v $(pwd)/scripts:/data:Z
docker run -d --rm \
-v $(pwd)/scripts:/data:Z \
-e PYTHON_SCRIPT_PATH="/data/myscript.py" \
-e CRON_SCHEDULE="*/10 * * * *" \
-e REQUIREMENTS_FILE="/data/requirements.txt" \
-e LOG_FILE_PATH="myscript.logs" \
gurkiratm/python-cron
Script output will be logged to:
${LOG_FILE_PATH} if provided
Or the default: /app/script_python_dYYYYMMDD_tHHMMSS.log
To view logs:
docker exec <container-name> cat <LOG-FILE-PATH>
docker logs <container-name>
docker build -t python-cron-runner .
Gurkirat Singh š§ [email protected]ā
Content type
Image
Digest
sha256:963c89451ā¦
Size
24.7 MB
Last updated
about 1 year ago
docker pull gurkiratm/python-cron