linux-systemd
systemd: unit files, systemctl, journalctl, cgroup integration, socket activation, OpenClaw service
What this skill does
# linux-systemd
## Purpose
This skill provides tools for managing systemd on Linux, focusing on service units, system control, logging, and integration features like cgroups and socket activation, specifically for OpenClaw service management.
## When to Use
Use this skill when you need to automate Linux service operations, such as starting/stopping daemons, monitoring logs, or optimizing resource usage with cgroups. Apply it in scripts for system administration, container orchestration, or when integrating OpenClaw as a systemd service. Avoid it on non-systemd systems like BSD or custom init setups.
## Key Capabilities
- Manage systemd unit files for services, sockets, and timers, including editing files in /etc/systemd/system/.
- Control services via systemctl commands, such as starting, stopping, and restarting units.
- Query logs with journalctl for real-time or historical output from specific units.
- Integrate cgroups for resource limits, e.g., CPU/memory constraints on services.
- Enable socket activation for on-demand service starts, reducing resource overhead.
- Handle OpenClaw as a systemd service by creating a unit file with ExecStart pointing to the OpenClaw binary.
## Usage Patterns
Always run commands with elevated privileges using sudo or as root. In scripts, use subprocess calls in Python or shell exec in Bash to invoke systemctl/journalctl. For unit file creation, edit files directly or use systemd-analyze for validation. When integrating with OpenClaw, ensure the service unit references the correct binary path and environment variables. Structure patterns as: detect service state first, then perform actions, and log outputs. For cgroups, specify limits in the unit file's [Service] section before reloading systemd.
## Common Commands/API
Use systemctl for service management: e.g., `systemctl start <unit>` to start a service. For logs, run `journalctl -u <unit> -f` to follow output. To restart, use `systemctl restart <unit> --no-block` for non-blocking operation. For cgroups, inspect with `systemctl status <unit> | grep CGroup` or set via unit file. Socket activation setup: add `Sockets=` in the unit file and use `systemctl start <socket-unit>`. Code snippet in Bash:
```
#!/bin/bash
systemctl stop my-service
systemctl start my-service
echo "Service restarted"
```
In Python, use:
```
import subprocess
subprocess.run(['systemctl', 'status', 'my-service'])
```
For OpenClaw service, create a unit file like:
```
[Unit]
Description=OpenClaw Service
[Service]
ExecStart=/usr/bin/openclaw --config /etc/openclaw/config.json
```
## Integration Notes
To integrate cgroups, add lines like `CPUQuota=50%` in the [Service] section of a unit file, then run `systemctl daemon-reload` and restart the unit. For socket activation, define a .socket unit file (e.g., `ListenStream=12345`) and link it to your service unit. When managing OpenClaw as a service, set environment variables in the unit file, e.g., `Environment="OPENCLAW_API_KEY=$SERVICE_API_KEY"`, and ensure $SERVICE_API_KEY is set via export in your shell or systemd environment files. Reload systemd with `systemctl daemon-reload` after changes. Avoid conflicts by checking for existing units with `systemctl list-units --type=service`.
## Error Handling
Always check command exit codes; for example, in Bash, use `if systemctl start <unit>; then echo "Success"; else echo "Failed: $?"; fi`. In Python, wrap subprocess calls in try-except blocks: try: subprocess.run([...], check=True) except subprocess.CalledProcessError as e: print(f"Error: {e.returncode}"). Common errors include "Failed to start unit" (check permissions or dependencies) or "Unit not found" (verify unit name with `systemctl list-units`). For journalctl, handle no logs with `journalctl -u <unit> --since "1 hour ago"` and parse output for errors. If cgroups fail, use `systemctl status <unit>` to debug limits, and ensure kernel support with `cat /proc/cgroups`.
## Concrete Usage Examples
Example 1: Start and monitor an OpenClaw service. First, create a unit file at /etc/systemd/system/openclaw.service with contents:
```
[Unit]
Description=OpenClaw Daemon
[Service]
ExecStart=/usr/bin/openclaw
```
Then, run: `systemctl daemon-reload; systemctl start openclaw; journalctl -u openclaw -f` to start and tail logs.
Example 2: Restart a service with cgroup limits. Edit the unit file to include `[Service] CPUQuota=30%`, then execute: `systemctl daemon-reload; systemctl restart my-service`. Verify with `systemctl status my-service | grep CGroup` to ensure CPU limits are applied.
## Graph Relationships
- Connected to: linux cluster (e.g., shares dependencies with other linux skills like file management or process control).
- Related via tags: systemd (direct link), services (e.g., to container or orchestration skills), linux (broad cluster ties), units (links to resource management skills).
- Integration points: cgroup (connects to performance monitoring tools), socket activation (relates to networking skills).
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.