About zeabur-service-exec
zeabur-service-exec is a skill for running commands inside a running Zeabur service container. It supports tasks such as inspecting files and environment variables, testing connectivity, and performing one-off database operations through the Zeabur CLI.
Key features
- 01Execute commands in service containers
- 02Inspect files and environment variables
- 03Run database queries and updates
- 04Select services by ID or name
- 05Target a specific environment
Use cases
- 01Inspect files while debugging a service
- 02Check container environment variables
- 03Run a one-off database query
- 04Test connectivity from a container
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ zeabur/ agent-skills --skill zeabur-service-execAfter installing, type/zeabur-service-execin Claude Code to confirm it loaded.
Details
From the project READMEZeabur Service Exec
Always use
npx zeabur@latestto invoke Zeabur CLI. Never usezeaburdirectly or any other installation method. Ifnpxis not available, install Node.js first.
Run commands inside a running service container. Useful for debugging, inspecting files, checking env vars, testing connectivity, or running one-off database operations.
Basic Usage
Commands and arguments go after --:
npx zeabur@latest service exec --id <service-id> -- <command> [args...]
Database Operations
# MongoDB - query, update, delete data
npx zeabur@latest service exec --id <mongodb-service-id> -- mongosh --eval 'db.users.find({})'
npx zeabur@latest service exec --id <mongodb-service-id> -- mongosh --eval 'db.sessions.deleteMany({title: /test/i})'
# PostgreSQL - run SQL queries (PGPASSWORD is set automatically in Zeabur containers)
npx zeabur@latest service exec --id <pg-service-id> -- psql -U postgres -c 'SELECT * FROM users LIMIT 10;'
# MySQL - run SQL queries (use env var to avoid interactive password prompt)
npx zeabur@latest service exec --id <mysql-service-id> -- sh -c 'mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "SHOW DATABASES;"'
# Redis - run commands
npx zeabur@latest service exec --id <redis-service-id> -- redis-cli KEYS '*'
Examples
# List files
npx zeabur@latest service exec --id <service-id> -- ls -la
# Check environment variables
npx zeabur@latest service exec --id <service-id> -- env
# Check a specific env var
npx zeabur@latest service exec --id <service-id> -- sh -c "echo \$DATABASE_URL"
# Test database connectivity
npx zeabur@latest service exec --id <service-id> -- sh -c "nc -zv postgres 5432"
# Check running processes
npx zeabur@latest service exec --id <service-id> -- ps aux
# Read a config file
npx zeabur@latest service exec --id <service-id> -- cat /app/config.json
# Check disk usage
npx zeabur@latest service exec --id <service-id> -- df -h
Flags
| Flag | Description |
|---|---|
--id | Service ID |
-n, --name | Service name (prefer --id) |
--env-id | Environment ID (if multiple environments) |
Tips
- The
--separator is required — everything after it is the command to run inside the container. - For compound commands, wrap in
sh -c "...". - Not all containers have a full shell —
shis more portable thanbash. - Use single quotes outside and double quotes inside when dealing with variable expansion:
sh -c "echo \$VAR". - To find service IDs, use the
zeabur-service-listskill. To check logs without exec, use thezeabur-deployment-logsskill. To manage env vars via CLI, use thezeabur-variablesskill.
Comments
Markdown supported