Skip to content

Artisan Commands

ske run runs a command against a deployed environment, with your application’s environment variables, database and cache. It waits for the command to end, prints its output and exits with its exit code.

Terminal window
ske run --env production php artisan migrate --force

Flags of ske go before the command: everything from the command’s first word on is sent as it is, so --force above goes to artisan, and --env must come before php. Quote a command that needs a shell’s quoting:

Terminal window
ske run "php artisan tinker --execute='echo User::count();'"

The command runs with sh -c in the application’s directory, in a dedicated invocation of the environment’s CLI function, isolated from web traffic. Its output comes back whole once it ends, cut in the middle if it is over 1 MB.

The dashboard’s Console tab on the environment runs commands the same way.

A command can’t be stopped once it has started: Ctrl-C stops waiting for it, not the command itself. ske run show <run-id> shows its result later.

There is no interactive session: ske run can’t answer prompts, so use --execute for tinker and --force or --no-interaction for commands that ask.

Terminal window
ske run list --limit 30
ske run show <run-id>

ske run list lists the environment’s recent runs: who ran what, when, and how it ended. To run a command named list or show, put it after --: ske run -- list.

Commands run on the CLI function, which has its own memory and timeout. Set them under the environment’s Settings, Compute, in the CLI part:

Setting Description Default
Memory Memory for commands, in MB (128 to 10,240) 512
Timeout Maximum time per command, in seconds (1 to 900) 900
Terminal window
# Run database migrations
ske run --env production php artisan migrate --force
# Clear caches
ske run --env staging php artisan cache:clear
# Run a custom command
ske run --env production php artisan app:import-data --source=s3

Caution: with a cache attached, cache:clear empties the whole Redis database the cache store is on, for every environment attached to that cache, and on a serverless cache also locks and anything else the app keeps in Redis. See Caches.