A simple Python package to make using CronMon in your cron jobs and scheduled tasks quick and easy.
cron-mon-py
can be installed via pip
- or your Python package manager of choice - like any other Python package you might install
pip install cron-mon-py
Simply import the monitor
decorator and use it on any function that serves as the entry point to your cron job/ scheduled task that you wish to monitor:
You'll need to have setup a Monitor and an API key within CronMon itself, and have exposed the API key in an environment variable called
CRON_MON_API_KEY
.
from cron_mon import monitor
# Replace <your-monitor-id> with your actual Monitor ID
@monitor("<your-monitor-id>")
def cron_job():
"""Your cron job code here"""
...
cron-mon-py
uses uv
to manage dependencies, so you'll need uv
installed to get setup to work on cron-mon-py
. You can either install uv
on your machine, or you can use the dev container provided in the repository if your IDE supports dev containers (hint: it's very well supported on Visual Studio Code).
Once you have uv
setup, you can use the Makefile
provided to install all dependencies and run the tests. The available commands are as follows:
install
: Install all of the required dependencies to work oncron-mon-py
static-tests
: Run static tests viaruff
andmypy
unit-tests
: Run unit tests viapytest
test
: Run all of the available tests forcron-mon-py
(static-tests
andunit-tests
)build
: Build the packagedocs
: Build the package's docsserve-docs
: Serve the package's documentation with hot-reloadformat
: Autoformat the code withruff
*
*You can avoid having to use
make format
if you setup your IDE to autoformat on save. The provided dev container has this already setup for you.