Docs menu

Tasks

A task runs a one-off command against a fresh copy of your app's current build, with the same secrets your app runs with.

On this page

A task runs a one-off command against a fresh copy of your app's current build: a database migration, a backfill, a seed, a cache clear, a script. Anything you'd shell into a server to run once, you run as a task.

A task isn't an interactive shell, and it isn't for work that should keep running. That belongs in a worker process in your Procfile; see Formations.

Running a task#

Enter a command in the Tasks box on the application's overview: php artisan migrate --force, rails db:analyze, node ./scripts/backfill.js, bin/cleanup.sh, whatever your app understands. It runs in the same region, on the same build, with the same secrets as your app, so it behaves as it would inside your running app.

A task run: the command across the top, a succeeded badge with its exit code, and the run's output below

A run starts as pending, moves to running once it starts, and ends as succeeded on a zero exit code or failed on anything else. A run still going after your plan's time limit (20 minutes on Standard, 45 on Pro, 60 on Team) is stopped, and you're billed only for the time it ran.

An environment can run tasks once it has had a successful deployment. Starting one needs your account in good standing; see Past-due & Suspension.

Output#

A task's output streams live while it runs and is kept afterward, separate from your app's logs and from other runs. See Logs.