Sign inSign up

gurkiratm/python-cron

By gurkiratm

•Updated about 1 year ago

Run any Python script on a custom cron schedule with environment-based configuration and logging.

Image
Networking
Developer tools
Monitoring & observability
0

324

gurkiratm/python-cron repository overview

ā šŸ•’ Python Cron Runner

Run any Python script on a custom cron schedule with environment-based control and logging.

Pull command:

docker pull gurkiratm/python-cron:latest

ā šŸ“¦ About

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.


ā šŸš€ Features

  • āœ… Run any script via PYTHON_SCRIPT_PATH
  • āœ… Schedule via CRON_SCHEDULE (default: 0 9 * * *)
  • āœ… Logs to dynamic or custom LOG_FILE
  • āœ… Virtualenv auto-created at /app/.venv
  • āœ… Installs requirements.txt via REQUIREMENTS_FILE (default: /app/requirements.txt)
  • āœ… Lightweight Alpine base image
  • āœ… Uses busybox crond running in foreground for clean logs

ā šŸ”§ Environment Variables

VariableRequiredDescription
PYTHON_SCRIPT_PATHāœ… YesFull path to the Python script inside the container
CRON_SCHEDULEāŒ NoCron format schedule (default: 0 9 * * *)
LOG_FILE_PATHāŒ NoLog file name (Default: /app/script_python_dYYYYMMDD_tHHMMSS.log)
REQUIREMENTS_FILEāŒ NoPath to requirements.txt (Default: /app/requirements.txt : empty)

ā šŸ“ Volume Mounts

Mount your Python script and any inputs:

-v $(pwd)/scripts:/data:Z

ā šŸ“„ Example Usage

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

ā šŸ“ Logs

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>

ā šŸ›  Build Locally

docker build -t python-cron-runner .


ā šŸ‘Øā€šŸ’» Maintainer

Gurkirat Singh šŸ“§ [email protected]⁠

Tag summary

Content type

Image

Digest

sha256:963c89451…

Size

24.7 MB

Last updated

about 1 year ago

docker pull gurkiratm/python-cron