Use the command line

Procrastinate installs a command-line tool, which allows to do some operations:

  • Prepare your database for procrastinate (apply the database schema)

  • Launch a worker

  • Defer a task

The command-line tool can be launched using:

$ procrastinate


$ python -m procrastinate

Please read the included help to get familiar with its commands and parameters:

$ procrastinate --help
usage: procrastinate [-h] [-a APP] [-v] [--log-format LOG_FORMAT]
                     [--log-format-style {%,{,$}] [-V]
                     {worker,defer,schema,healthchecks,shell} ...

Interact with a Procrastinate app. See subcommands for details.

positional arguments:
    worker              Launch a worker, listening on the given queues (or all
                        queues). Values default to App.worker_defaults and
                        then App.run_worker() defaults values.
    defer               Create a job from the given task, to be executed by a
                        worker. TASK should be the name or dotted path to a
                        task. JSON_ARGS should be a json object (a.k.a
                        dictionary) with the job parameters
    schema              Apply SQL schema to the empty database. This won't
                        work if the schema has already been applied.
    healthchecks        Check the state of procrastinate
    shell               Administration shell for procrastinate

  -h, --help            show this help message and exit
  -a APP, --app APP     Dotted path to the Procrastinate app (env:
                        PROCRASTINATE_APP) (default: )
  -v, --verbose         Use multiple times to increase verbosity (env:
                        PROCRASTINATE_VERBOSE: set to desired verbosity level)
                        (default: 0)
  -V, --version         Print the version and exit

  --log-format LOG_FORMAT
                        Defines the format used for logging (see https://docs.
                        attributes) (env: PROCRASTINATE_LOG_FORMAT) (default:
  --log-format-style {%,{,$}
                        Defines the style for the log format string (see
                        (env: PROCRASTINATE_LOG_FORMAT_STYLE) (default: %)

Define your app

When using the Procrastinate CLI, you’ll almost always need to specify your app. This can be done in two ways:

  • Using the --app parameter:

    $ procrastinate worker
  • Using the PROCRASTINATE_APP environment variable:

    $ export
    $ procrastinate worker

As a general rule, all parameters have an environment variable equivalent, named PROCRASTINATE_SOMETHING or PROCRASTINATE_SUBCOMMAND_SOMETHING where SOMETHING is the uppercased long name of the option, with - replaced with _ (e.g. PROCRASTINATE_DEFER_UNKNOWN). procrastinate --help will show you the environment variable equivalent of each parameter.

In both case, the app you specify must have an asynchronous connector.


Three different options allow you to control how the command-line tool should log events:

  • Verbosity controls the log level (you’ll see message of this level and above):


    Environment equivalent

    Log level









  • Log format: --log-format= / PROCRASTINATE_LOG_FORMAT= lets you control how the log line will be formatted. It uses %-style placeholders by default.

  • Log format style: --log-format-style= / PROCRASTINATE_LOG_FORMAT_STYLE= lets you choose different styles for the log-format, such as { or $.

For more information on log formats, refer to the Python documentation