Devpilot
Servers

Scripts and Automation

Create, execute, schedule, version, and chain bash scripts on your servers. Use AI assistance, webhooks, metric triggers, secrets, and multi-server execution.

Scripts and Automation

Devpilot provides a full-featured scripting environment for your servers. You can write bash scripts directly in the platform, run them with live streaming output, schedule them on recurring intervals, chain them with triggers and workflows, run them across many servers at once, and trigger them from external services through webhooks. An integrated AI assistant helps you generate, explain, debug, and optimize scripts without leaving the editor, and every edit is snapshotted so you can always roll back.

This page covers the fundamentals. For each advanced feature, the dedicated sub-pages linked from Advanced Automation go deeper.

Creating and Running a Script

On a server's dashboard, open the Scripts tab. This lists every script associated with the server, whether you created it manually, from a template, or via AI.

Create a new script

Click Create Script and provide:

  • Name — A descriptive label, for example Clear app cache or Rotate logs. Required, max 255 characters.
  • Script content — The script body. Required. Devpilot executes bash end-to-end; other languages (Python, Node, PHP, or custom) can be stored and assisted by AI, but you'll typically wrap them in a bash call or interpreter invocation on the server.
  • Description — Optional short explanation, up to 500 characters.
  • Category — Optional free-form label (max 50 chars). Useful for filtering in the list.
  • Tags — Optional list of tags (each up to 50 chars).
  • Run as — The OS user to execute the script under (for example root, ubuntu, deploy). Up to 100 characters.
  • Schedule — Optional cron expression (up to 100 chars). Turn on Scheduled to enable recurring runs.
  • Timeout — Per-run timeout in seconds, 1 to 3600.

Prefer a plain-language prompt over writing from scratch? Use the AI Script Assistant to draft a script — see AI Script Assistance.

Execute the script

Open the script and click Execute. Devpilot opens an SSH session and runs the script, streaming stdout and stderr to your browser line by line. When the script completes, the execution record stores:

  • Exit code — The script's exit code.
  • Duration — Wall-clock duration of the run.
  • Output — Captured stdout (up to 65,535 characters).
  • Error — Captured stderr (up to 5,000 characters).
  • StatusCompleted, Failed, or Cancelled.
  • Trigger — How the run was initiated (manual, webhook, trigger, workflow, or schedule).

Review execution history

Every run is logged and visible in the script's Execution History panel. Each entry shows timestamp, duration, trigger type, status, and exit code. Click an entry to see the full streamed output.

Managing Scripts

Beyond creating and running, each script supports:

  • Duplicate — Copy a script as a starting point for a new one. The copy resets the run counters and unpins.
  • Pin — Pin a frequently used script to the top of the list.
  • Version history — Every save that changes the body creates a new version. Browse and restore from the History tab. See Script Versions.
  • Run counters — Each script shows its execution count and last-run time so you can see how active it is.

Scheduled Scripts

A script can run automatically on a schedule. Open the script, toggle Scheduled on, and provide a cron expression in the Schedule field. Scheduled runs show up in the execution history marked as scheduled.

Scheduled scripts continue to run whether or not you're logged in. Attach a Notification Channel if you want to be alerted on success or failure.

Webhooks

Every script can expose one or more HTTP webhook endpoints that trigger execution when called. Open the script and go to the Webhooks tab to create one. Each webhook has:

  • A 64-character random token used to authenticate calls.
  • Optional IP allowlist (list of IPs).
  • Optional HMAC secret for request signing.

Callers POST to Devpilot's shared webhook endpoint with the token in the JSON body; Devpilot validates, runs the script in streaming mode on the server, and returns the queued execution details. Each webhook invocation is logged as a script execution marked with the Webhook trigger.

Details, example requests, and security best practices are in Script Webhooks.

Triggers

Triggers let a script run when a server metric crosses a threshold. Each trigger has:

  • Metric — CPU usage, memory usage, disk usage, or service down.
  • Operator — Greater than, greater-than-or-equal, less than, less-than-or-equal, or equal.
  • Threshold — The value to compare against.
  • Duration — How long the condition must hold before firing. Range 0–3600 seconds, default 300.
  • Cooldown — Minimum minutes between firings. Range 1–1440, default 30.
  • Active — Whether the trigger is armed. On by default.
  • Last triggered and trigger count — Populated automatically for auditing.

Use triggers to run a disk-cleanup script when disk usage crosses 85% or restart a worker when memory pressure spikes. Full rules and examples are in Script Triggers.

Workflows

When a job needs multiple steps, chain scripts into a Workflow. Each step is a saved script with its own timeout plus On success and On failure behavior (continue to the next step, end the workflow, stop, keep going, or jump to a specific step for rollback paths). Workflows can be triggered manually, on a cron schedule, or by a webhook — and every run is captured with per-step results and total duration.

See Script Workflows for branching patterns and full examples.

Multi-Server Execution

When you need to run the same script across several servers, open a script and click Run on Multiple Servers. Pick targets, choose:

  • Execution modeParallel (default) or Sequential.
  • Failure strategyContinue (default) or Stop on first failure.

Devpilot records one parent run plus one child result per server (capturing each server's name, status, output, error, exit code, and duration). You can audit the fleet-wide outcome at a glance and drill into individual server runs.

Full request payload and real-world examples are in Multi-Server Execution.

AI Script Assistance

Devpilot includes an AI-powered helper in the script editor. Click AI Assist to open it. The assistant supports four actions, each accepting an optional language (bash, Python, Node, PHP, or custom):

  • Generate — Describe what you want ("alert if any disk is over 90%") and receive a complete script, suggested name, description, category, and tags.
  • Explain — Paste a script and get a structured walkthrough (summary, steps, prerequisites, risks, suggestions).
  • Debug — Feed the script plus the error output and receive a diagnosis plus a fixed version.
  • Optimize — Submit a working script and get a refactored version with explanations.

Details, limits, and the full response shape are in AI Script Assistance.

Script Templates

The Templates Library ships pre-built scripts for common server tasks:

  • System maintenance (log rotation, temp file cleanup, package updates).
  • Application management (service restarts, cache clears, queue management).
  • Database operations (dumps, restores, health checks).
  • Security tasks (audit logging, file-integrity spot checks).
  • Monitoring and alerting (resource thresholds, uptime pings).

Each template records its name, description, category, and script body. Click Use Template to create a new script pre-populated with the template contents, which you can then customize and save. Templates are filterable by category and searchable by name/description.

Script Secrets

Scripts often need access to sensitive values — API keys, database passwords, tokens. Instead of hardcoding them, use Script Secrets.

Each secret has:

  • A key in strict uppercase format — it must start with a capital letter and contain only capital letters, numbers, and underscores (for example DB_PASSWORD).
  • An encrypted value (never returned in plain text after save).
  • An optional description.
  • An optional server scope — when set, the secret is scoped to that server; when empty, it's workspace-wide.

Reference a secret in your script body with the placeholder {{secret.KEY}}:

mysqldump -u app -p"{{secret.DB_PASSWORD}}" app_production > /tmp/db.sql

Devpilot substitutes the decrypted value just before execution, so the saved script body and Script Versions history never contain the raw secret. When both a server-scoped and a workspace-wide secret share a key, the server-scoped one wins.

Secret values aren't displayed in plain text after creation. You can update or delete them, but you can't read the original value back out of Devpilot.

More detail (rotation, quoting tips, limits) is in Script Secrets.

Notification Channels

Configure Notification Channels at the workspace level so script runs can notify you on success, failure, or both. Each channel has a type and its own configuration (webhook URL, email address, chat integration, etc.) and an Active toggle so you can pause channels without deleting them.

Attach one or more channels to a script to be alerted when manual, scheduled, webhook-triggered, or threshold-triggered runs complete.

Advanced Automation

The sections above cover day-to-day scripting. When you're ready to go further, Devpilot groups the advanced features into dedicated sub-pages:

  • Script Workflows — Chain multiple scripts into a single pipeline with conditional branching (on success / on failure), run history, and optional scheduling.
  • Script Triggers — Run a script when a server metric (CPU usage, memory usage, disk usage, or service down) crosses a threshold, with duration and cooldown controls.
  • Script Webhooks — Expose a script as a tokenized HTTP endpoint, with optional IP allowlist and HMAC signature verification.
  • Script Secrets — Store API keys, passwords, and tokens encrypted at rest and reference them with {{secret.KEY}} placeholders.
  • Script Versions — Every save creates a snapshot. Browse, diff, and restore any previous version.
  • Multi-Server Execution — Run one script across many servers in parallel or sequentially, with aggregate result tracking.
  • AI Script Assistance — Generate, explain, debug, and optimize scripts from inside the editor.

Next Steps