systemd
systemd unit file authoring and system management skill: service units, timer units, socket activation, drop-in overrides, journalctl, and security hardening options. USE WHEN: - Writing or modifying systemd service unit files for Node.js, Python, Go, or other apps - Setting up automatic restarts, dependency ordering, and environment variable loading - Creating timer units as a cron replacement for periodic tasks - Hardening a service with PrivateTmp, NoNewPrivileges, ProtectSystem=strict, etc. - Using drop-in overrides to modify upstream package-provided unit files - Debugging service startup failures, missing env vars, or timer misfires - Managing logs with journalctl (filtering, following, exporting) DO NOT USE FOR: - Docker container orchestration (use docker or kubernetes skill) - Application-level scheduling (job queues, cron-based business logic — use job-queues skill) - Full init system replacement on non-systemd distros (Alpine uses OpenRC) - Windows Task Scheduler or macOS launchd equivalents
What this skill does
# systemd — Unit Files and System Management ## Unit File Anatomy systemd units live in: - `/lib/systemd/system/` — package-installed units (do not edit directly) - `/etc/systemd/system/` — administrator units; override package units with same name - `/etc/systemd/system/<name>.service.d/` — drop-in overrides (preferred) Unit files use INI-style sections. Key sections for a service: ``` [Unit] — metadata, dependencies, ordering [Service] — what to run and how to manage it [Install] — how to enable/disable (which targets want this unit) ``` --- ## Production Service Unit Template Save as `/etc/systemd/system/myapp.service`: ```ini [Unit] Description=My Application Server Documentation=https://docs.example.com/myapp # Ordering: start after network is up and PostgreSQL is ready After=network-online.target postgresql.service Wants=network-online.target # Hard dependency: if PostgreSQL stops, this unit also stops Requires=postgresql.service [Service] # --- Process type --- # simple: ExecStart is the main process; systemd tracks it directly # forking: process daemonises (old-style); set PIDFile= # notify: process signals systemd via sd_notify() when ready # oneshot: for scripts that run and exit; combine with RemainAfterExit=yes Type=notify # --- Identity --- User=myapp Group=myapp WorkingDirectory=/opt/myapp # --- Environment --- # Load secrets from a file not checked into source control EnvironmentFile=/etc/myapp/environment # Inline env vars (for non-secret values) Environment=NODE_ENV=production Environment=PORT=3000 # --- Process lifecycle --- ExecStartPre=/opt/myapp/scripts/pre-start.sh # Validation / migration ExecStart=/usr/bin/node /opt/myapp/dist/server.js ExecStop=/bin/kill -SIGTERM $MAINPID # Graceful shutdown signal ExecStopPost=/opt/myapp/scripts/post-stop.sh # Cleanup after stop ExecReload=/bin/kill -SIGHUP $MAINPID # Signal for config reload (if supported) # --- Restart behaviour --- Restart=on-failure # Restart if process exits non-zero or is killed RestartSec=5s # Wait 5 seconds before restarting StartLimitIntervalSec=60s # Window for counting start attempts StartLimitBurst=5 # Max 5 starts in 60s; unit enters failed state after # --- Resource limits --- LimitNOFILE=65535 # Open file descriptors (overrides /etc/security/limits.conf) LimitNPROC=4096 # Max subprocesses MemoryMax=2G # OOM-kill process if it exceeds 2 GB (cgroup-based) CPUQuota=200% # Max 2 CPU cores (200% of one core = 2 cores) TasksMax=512 # Max number of tasks (threads + processes) # --- Output logging --- StandardOutput=journal # stdout → journal StandardError=journal # stderr → journal SyslogIdentifier=myapp # Tag in journal (default: unit name without .service) # --- Security hardening --- PrivateTmp=true # Mount private /tmp and /var/tmp (other services can't see them) NoNewPrivileges=true # Prevent setuid/setgid; process can't gain more privileges ProtectSystem=strict # /usr, /boot, /etc are read-only ProtectHome=true # /home, /root, /run/user are inaccessible ReadWritePaths=/var/lib/myapp /var/log/myapp # Exceptions to ProtectSystem=strict PrivateDevices=true # No access to physical devices ProtectKernelTunables=true # Block writes to /proc/sys ProtectKernelModules=true # Block kernel module loading ProtectControlGroups=true # Block cgroup manipulation RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX # Restrict socket families RestrictNamespaces=true # Block namespace creation SystemCallFilter=@system-service # Whitelist common syscalls; block dangerous ones # --- Timeout --- TimeoutStartSec=30s # Fail if not ready within 30s (for Type=notify) TimeoutStopSec=30s # Force-kill after 30s if graceful stop takes too long [Install] WantedBy=multi-user.target # Enable via: systemctl enable myapp ``` --- ## EnvironmentFile Pattern for Secrets ```bash # /etc/myapp/environment (mode 600, owned by root or myapp user) DATABASE_URL=postgresql://myapp:secret@localhost:5432/myapp_prod SECRET_KEY=your-256-bit-random-key-here AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY REDIS_URL=redis://:password@localhost:6379/0 ``` ```bash # Set correct permissions sudo install -m 600 -o root -g root /dev/stdin /etc/myapp/environment <<'EOF' DATABASE_URL=... EOF # Or for apps running as a specific user sudo install -m 640 -o root -g myapp /dev/stdin /etc/myapp/environment <<'EOF' DATABASE_URL=... EOF ``` The `EnvironmentFile` path in the unit file reads each `KEY=VALUE` line. Lines starting with `#` are ignored. A leading `-` makes the file optional: `EnvironmentFile=-/etc/myapp/environment`. --- ## Timer Unit — Daily Backup Job ### /etc/systemd/system/backup-myapp.service ```ini [Unit] Description=Daily backup of myapp database After=network-online.target Wants=network-online.target [Service] Type=oneshot User=backup Group=backup EnvironmentFile=/etc/myapp/environment ExecStart=/opt/myapp/scripts/backup.sh StandardOutput=journal StandardError=journal SyslogIdentifier=backup-myapp ``` ### /etc/systemd/system/backup-myapp.timer ```ini [Unit] Description=Run myapp backup daily at 02:30 UTC Requires=backup-myapp.service [Timer] # OnCalendar format: DayOfWeek Year-Month-Day Hour:Minute:Second # Shortcuts: minutely, hourly, daily, weekly, monthly, yearly, quarterly OnCalendar=*-*-* 02:30:00 # Every day at 02:30 UTC Persistent=true # If timer was missed (machine off), run immediately on next boot RandomizedDelaySec=10min # Jitter to avoid thundering herd on multiple servers AccuracySec=1min # Allow 1 minute timing inaccuracy for better power management [Install] WantedBy=timers.target ``` ```bash sudo systemctl daemon-reload sudo systemctl enable --now backup-myapp.timer # Verify timer status sudo systemctl list-timers backup-myapp sudo systemctl status backup-myapp.timer # Trigger immediately (for testing) sudo systemctl start backup-myapp.service ``` ### OnCalendar Syntax Examples ``` OnCalendar=minutely # Every minute OnCalendar=hourly # Every hour at :00 OnCalendar=daily # Every day at 00:00 OnCalendar=weekly # Every Monday at 00:00 OnCalendar=monthly # First day of month at 00:00 OnCalendar=*-*-* 02:30:00 # Every day at 02:30 OnCalendar=Mon *-*-* 03:00:00 # Every Monday at 03:00 OnCalendar=*-*-1 04:00:00 # First of every month at 04:00 OnCalendar=*-*-* *:0/15:00 # Every 15 minutes OnCalendar=Mon..Fri *-*-* 09:00:00 # Weekdays at 09:00 # Verify calendar expression without executing systemd-analyze calendar "Mon *-*-* 09:00:00" ``` --- ## Drop-In Overrides Override a package-provided unit without editing the original file: ```bash # Opens editor; creates /etc/systemd/system/nginx.service.d/override.conf sudo systemctl edit nginx # Create override manually sudo mkdir -p /etc/systemd/system/nginx.service.d/ sudo tee /etc/systemd/system/nginx.service.d/limits.conf > /dev/null <<'EOF' [Service] # Raise open file descriptor limit for Nginx LimitNOFILE=65535 # Add environment variable Environment=MALLOC_ARENA_MAX=2 EOF sudo systemctl daemon-reload sudo systemctl restart nginx # Show effective merged unit (original + all drop-ins) sudo systemctl cat nginx ``` Drop-in files in `<name>.service.d/` are applied alphabetically. Use numeric prefixes (e.g., `10-limits.conf`, `20-env.conf`) to control order. --- ## Socket Activation systemd can hold a listening socket and pass it to the service on first connection. The service doesn't need to be running all the time. ### /etc/systemd/system/myapp.socket ```ini [Unit] Description=myapp socket activation [Socket] ListenStream=127.0.0.1:3000 # Or: ListenStream=/run/myapp/myapp.sock Accept=false # false = pass socke
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.