FastAPI-Cronsv2.4.0

Invoking the CLI

The CLI is a module, run with python -m:

bash
python -m fastapi_crons.cli --help

There is no fastapi-crons console script

The package does not install a standalone fastapi-crons command, and python -m fastapi_crons does not work either — there is no __main__ module. Always use python -m fastapi_crons.cli.

Commands

CommandPurpose
list-jobsList registered jobs with their status.
run-job NAMERun one job immediately.
statusOverall system status.
logsShow job execution logs.
config-showPrint the active configuration.
config-setSet a configuration value.
start-schedulerRun the scheduler without a web server.

Every command accepts --help for its own options.

Examples

bash
python -m fastapi_crons.cli list-jobs
python -m fastapi_crons.cli run-job backup_database
python -m fastapi_crons.cli status
python -m fastapi_crons.cli logs --job backup_database
python -m fastapi_crons.cli config-show
python -m fastapi_crons.cli start-scheduler

The CLI reads the same state as your app

It connects to the state backend configured through the environment, so it reports what your running application recorded. Point it at the same CRON_SQLITE_DB_PATH or CRON_REDIS_URL your app uses, or it will read an empty database and show nothing.

Jobs must be importable to be listed

Job definitions live in your application code. Run the CLI from the same working directory and virtual environment as your app so the module that registers them can be imported.

Running the scheduler without a web server

start-scheduler runs the job loops on their own, which is useful if you want scheduled work in a dedicated process rather than inside your API replicas.

bash
python -m fastapi_crons.cli start-scheduler
Esc
IntroductionGetting StartedInstallationGetting StartedQuick StartGetting StartedCron ExpressionsCore ConceptsDefining JobsCore ConceptsHooksCore ConceptsConfigurationCore ConceptsState BackendsBackendsDistributed LockingBackendsDashboardOperationsHTTP EndpointsOperationsCLIOperations