Skip to content
Skillv1.0.0

systemd

Manage Linux services with systemd. Use when a user asks to create a system service, run an app on boot, manage background processes, set up timers (cron replacement), or configure service dependencie

by terminalskills(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from terminalskills/skills (skills/systemd/SKILL.md). Install upstream with npx skills add terminalskills/skills --skill systemd. Copyright stays with the author (Apache-2.0).

systemd

Overview

systemd manages Linux services — start, stop, restart, enable on boot, and monitor processes. It replaces init scripts with declarative unit files. Handles dependencies, auto-restart, logging (journald), resource limits, and timers (cron replacement).

Instructions

Step 1: Create a Service

# /etc/systemd/system/myapp.service — Node.js app as a system service
[Unit]
Description=My Node.js Application
After=network.target postgresql.service
Wants=postgresql.service

[Service]
Type=simple
User=deploy
Group=deploy
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/node dist/server.js
Restart=always
RestartSec=5
Environment=NODE_ENV=production
Environment=PORT=3000
EnvironmentFile=/opt/myapp/.env

# Security hardening
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/myapp/uploads

# Resource limits
MemoryMax=512M
CPUQuota=80%

[Install]
WantedBy=multi-user.target

Step 2: Manage Service

sudo systemctl daemon-reload          # reload after editing unit files
sudo systemctl enable myapp            # start on boot
sudo systemctl start myapp             # start now
sudo systemctl status myapp            # check status
sudo systemctl restart myapp           # restart
sudo systemctl stop myapp              # stop
journalctl -u myapp -f                 # view live logs
journalctl -u myapp --since "1 hour ago"  # recent logs

Step 3: Timer (Cron Replacement)

# /etc/systemd/system/backup.timer — Run backup daily at 3 AM
[Unit]
Description=Daily Backup Timer

[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true

[Install]
WantedBy=timers.target
# /etc/systemd/system/backup.service — The actual backup job
[Unit]
Description=Database Backup

[Service]
Type=oneshot
User=deploy
ExecStart=/opt/scripts/backup.sh
sudo systemctl enable --now backup.timer
systemctl list-timers                    # list active timers

Guidelines

  • Always run daemon-reload after changing unit files.
  • Use Restart=always for production services — systemd auto-restarts on crash.
  • journalctl -u service -f is the primary log viewer — replaces checking log files.
  • Timers are better than cron: persistent (catch up missed runs), dependency-aware, logged.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/terminalskills-skills-systemd/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

terminalskills-skills-systemd.ocm.jsonjson
{
  "ocm": "1",
  "id": "terminalskills-skills-systemd",
  "kind": "skill",
  "name": "systemd",
  "description": "Manage Linux services with systemd. Use when a user asks to create a system service, run an app on boot, manage background processes, set up timers (cron replacement), or configure service dependencies and auto-restart.",
  "publisher": "terminalskills",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "systemd",
      "linux",
      "services",
      "daemon",
      "process-management",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Manage Linux services with systemd. Use when a user asks to create a system service, run an app on boot, manage background processes, set up timers (cron replacement), or configure service dependencies and auto-restart."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/terminalskills/skills",
      "path": "skills/systemd/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/terminalskills/skills/blob/HEAD/skills/systemd/SKILL.md",
      "key": "terminalskills/skills/skills/systemd/SKILL.md"
    },
    "compatibility": "Linux (systemd-based: Ubuntu, Debian, CentOS, Fedora, Arch)",
    "license": "Apache-2.0"
  },
  "instructions": "# systemd\n\n## Overview\n\nsystemd manages Linux services — start, stop, restart, enable on boot, and monitor processes. It replaces init scripts with declarative unit files. Handles dependencies, auto-restart, logging (journald), resource limits, and timers (cron replacement).\n\n## Instructions\n\n### Step 1: Create a Service\n\n```ini\n# /etc/systemd/system/myapp.service — Node.js app as a system service\n[Unit]\nDescription=My Node.js Application\nAfter=network.target postgresql.service\nWants=postgresql.service\n\n[Service]\nType=simple\nUser=deploy\nGroup=deploy\nWorkingDirectory=/opt/myapp\nExecStart=/usr/b",
  "cost": {
    "context_tokens": 569
  }
}

Fetch it by URL: GET /api/v1/registry/terminalskills-skills-systemd/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.

systemd - Skill - OpenSmartRoute