cpln workload cron run command runs a command using a persistent suspended cron workload. The runner workload is created on first use and reused for subsequent runs, avoiding the overhead of creating and deleting a workload each time.
When to use this
Run migrations
Execute database migrations with fast startup times
Recurring scripts
Run maintenance scripts repeatedly without workload creation overhead
Background jobs
Fire-and-forget jobs that run without blocking your terminal
Interactive debugging
Connect to an interactive session inside the runner workload
Prerequisites
CLI installed
CLI installed
Install the Control Plane CLI. See Installation.
Required permissions
Required permissions
You need
create and exec permissions on workloads. See Workload Permissions.Basic usage
- Creates a persistent suspended cron workload as the runner
- Starts a job execution with your command
- Waits for the job to complete and outputs the result
Options
| Option | Description |
|---|---|
--image | Override image |
-i, --interactive | Make the session interactive |
-b, --background | Run in background without waiting for completion (fire and forget) |
-t, --timeout <seconds> | Maximum time to wait for job completion (default: 600) |
--cpu | Set allocated CPU for the main container |
--memory, --mem | Set allocated memory for the main container |
--env | Environment variables in KEY=VALUE format (can be specified multiple times) |
-s, --shell | Shell to use when interactive flag is true (default: bash) |
--location | Location to run the command |
--container | Which container to run the command in |
--tag | Attach tags (e.g., --tag drink=water) |
Execution modes
Default (wait for completion)
Waits for the job to complete and outputs the final status:Background mode
Fires and forgets, outputting the job ID immediately:Interactive mode
Waits for the job to start, then connects via WebSocket for an interactive terminal session:Specify a shell
Use a custom image
Common workflows
The cron runner uses
ubuntu:latest by default, which won’t have your application tools (Node.js, Python, etc.). Use --image to specify an image that has the tools your command needs.Run database migrations
Run data processing in the background
Pass environment variables
Run in a specific location
The specified location must be enabled in your GVC. You can check your GVC’s locations with
cpln gvc get <gvc-name>.Add tags for tracking
Resource configuration
Override CPU and memory for resource-intensive tasks:Troubleshooting
Timeout waiting for job completion
Timeout waiting for job completion
The default timeout is 600 seconds. For long-running tasks, specify an image with the tools you need and increase the timeout:Alternatively, use
--background for tasks that don’t need to wait for completion.Command not found
Command not found
The default image may not have your tool. Use a custom image:
Shell not available
Shell not available
Specify a different shell for interactive sessions: