lift cron

Manage scheduled cron jobs on the server with support for container and host job types, overlap policies, retry strategies, and execution history.

lift cron

Manage scheduled cron jobs for containers and host scripts running on the server. Jobs are managed via /etc/cron.d/onelift-jobs with config stored in /opt/onelift/config/jobs/.

Job Types

TypeDescriptionUse Case
containerExecute script inside a Docker containerApplication-level tasks: database cleanup, cache flush, report generation
hostExecute script directly on the hostSystem-level tasks: disk cleanup, backup rotation, log management

Container jobs pipe the script into the container via docker exec -i, so the script runs with access to the container's filesystem, tools, and environment. You select the target container by name (e.g., strapi-app, redis-app).

Host jobs run directly on the server as root via cron. The script has full access to the host filesystem and all Docker commands.

Subcommands

lift cron add

Add a new scheduled cron job.

FlagDescriptionDefault
--name <name>Job display name (required)-
--schedule <expr>Cron expression, 5 fields: min hour dom mon dow (required)-
--container <name>Target container name (required for container type)-
--command <cmd>Inline command to execute-
--script-file <path>Local file to read script from-
--type <type>Job type: container or hostcontainer
--timeout <seconds>Max execution time in seconds (10-3600)300
--overlap <policy>Overlap policy: skip, queue, or killskip
--env KEY=VALUEEnvironment variables (repeatable)-
--retry-max <n>Max retry attempts on failure0
--retry-delay <seconds>Retry delay in seconds10
--retry-backoff <type>Retry backoff: fixed or exponentialfixed
# Container job: run cleanup script inside strapi container every day at 3 AM
lift cron add --name "DB Cleanup" --container strapi-app --command "node scripts/cleanup.js" --schedule "0 3 * * *"

# Host job: run disk cleanup every Sunday at 2 AM with queue overlap
lift cron add --name "Disk Cleanup" --type host --script-file ./cleanup.sh --schedule "0 2 * * 0" --overlap queue

# Multi-line script from file with retry
lift cron add --name "Data Sync" --container app --script-file ./sync.sh --schedule "*/30 * * * *" --timeout 120 --retry-max 3 --retry-backoff exponential

# With environment variables
lift cron add --name "Weekly Report" --container app --command "node report.js" --schedule "0 8 * * 1" --env REPORT_TYPE=weekly --env SEND_EMAIL=true

When using --script-file, the file contents are uploaded to the server. For container jobs, the script is piped into the container at execution time.

lift cron list

List all scheduled cron jobs, including disabled jobs.

lift cron list
lift cron list --output jsonl

Output columns: NAME, SLUG, TYPE, CONTAINER, SCHEDULE, TIMEOUT, OVERLAP, ENABLED

lift cron status

Show detailed status of all cron jobs including last run info and exit codes.

lift cron status

Output columns: NAME, SLUG, TYPE, SCHEDULE, ENABLED, OVERLAP, LAST RUN, EXIT CODE

lift cron run <name>

Run a scheduled cron job immediately, streaming output to the terminal.

lift cron run "DB Cleanup"

lift cron history <name>

Show the execution history for a job. Each run is logged to /var/log/onelift/jobs/<slug>/history.jsonl.

FlagDescriptionDefault
--limit <n>Maximum number of history entries to show50
lift cron history "DB Cleanup"
lift cron history "DB Cleanup" --limit 20

Shows: date, duration, exit code, status (OK/FAILED/TIMEOUT/SKIPPED), and success rate.

lift cron edit <name>

Open the job's script file in your $EDITOR for modification. The script is downloaded from the server, opened locally, and uploaded back after editing.

lift cron edit "DB Cleanup"

If $EDITOR is not set, defaults to vi.

lift cron enable <name>

Enable a previously disabled cron job, adding it back to the cron schedule.

lift cron enable "DB Cleanup"

lift cron disable <name>

Disable a cron job without removing it. The job config and script are preserved.

lift cron disable "DB Cleanup"

lift cron remove <name>

Remove a cron job completely. Deletes the config, script, and log files from the server.

lift cron remove "DB Cleanup"

lift cron log <name>

Show the latest log output for a cron job.

lift cron log "DB Cleanup"

lift cron sync

Push all server-side cron job definitions to the web dashboard. Reads job configs from /opt/onelift/config/jobs/ and syncs them to the platform API using credentials stored on the server.

This is automatically called after lift cron add and lift cron remove, so you typically only need to run it manually if jobs were created directly on the server or if the dashboard is out of sync.

lift cron sync

Overlap Policies

Controls what happens when a job is triggered while a previous instance is still running.

PolicyBehaviorUse Case
skipSkip this execution if already runningDefault. Safe for most jobs.
queueWait for the running instance to finish, then runWhen every execution matters (e.g., data processing)
killKill the running instance and start a new oneWhen only the latest execution matters

Overlap is enforced using flock on /tmp/onelift-job-<slug>.lock.

Retry Policies

When a job fails (non-zero exit code), it can be automatically retried.

OptionDescription
--retry-maxNumber of retry attempts (0 = no retry)
--retry-delaySeconds to wait between retries
--retry-backoff fixedSame delay between all retries
--retry-backoff exponentialDelay doubles after each retry (delay, delay2, delay4, ...)
# Retry 3 times with 10s fixed delay
lift cron add --name "Task" --container app --command "node task.js" --schedule "0 * * * *" --retry-max 3 --retry-delay 10

# Retry 5 times with exponential backoff (10s, 20s, 40s, 80s, 160s)
lift cron add --name "Task" --container app --command "node task.js" --schedule "0 * * * *" --retry-max 5 --retry-delay 10 --retry-backoff exponential

Server File Structure

/opt/onelift/bin/onelift-job-runner.sh          # Job runner script
/opt/onelift/config/jobs/<slug>.json            # Per-job config
/opt/onelift/scripts/jobs/<slug>.sh             # Per-job script
/var/log/onelift/jobs/<slug>/history.jsonl       # Execution history
/var/log/onelift/jobs/<slug>/run_<timestamp>.log # Per-run output
/var/log/onelift/jobs/<slug>/latest.log          # Symlink to latest run
/etc/cron.d/onelift-jobs                        # Cron schedule file

Cron Expression Reference

Five fields: minute hour day-of-month month day-of-week

FieldRangeSpecial
Minute0-59*, ,, -, /
Hour0-23*, ,, -, /
Day of Month1-31*, ,, -, /
Month1-12*, ,, -, /
Day of Week0-7 (0,7=Sun)*, ,, -, /
0 3 * * *       Every day at 3:00 AM
*/15 * * * *    Every 15 minutes
0 0 * * 0       Every Sunday at midnight
0 8 * * 1-5     Weekdays at 8:00 AM
0 */6 * * *     Every 6 hours
30 2 1 * *      First of every month at 2:30 AM