linux-systemd
systemd: unit files, systemctl, journalctl, cgroup integration, socket activation, OpenClaw service
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o linux-systemd.zip https://jpskill.com/download/22240.zip && unzip -o linux-systemd.zip && rm linux-systemd.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/22240.zip -OutFile "$d\linux-systemd.zip"; Expand-Archive "$d\linux-systemd.zip" -DestinationPath $d -Force; ri "$d\linux-systemd.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
linux-systemd.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
linux-systemdフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
linux-systemd
目的
このスキルは、Linux上でsystemdを管理するためのツールを提供します。特に、サービスユニット、システム制御、ロギング、およびcgroupsやソケットアクティベーションのような統合機能に焦点を当てており、OpenClawサービス管理に特化しています。
使用する場面
デーモンの起動/停止、ログの監視、cgroupsによるリソース使用量の最適化など、Linuxサービス操作を自動化する必要がある場合にこのスキルを使用します。システム管理、コンテナオーケストレーションのスクリプト、またはOpenClawをsystemdサービスとして統合する際に適用してください。BSDやカスタムinitセットアップのような非systemdシステムでは使用を避けてください。
主要な機能
- サービス、ソケット、タイマーのsystemdユニットファイルを管理します。これには、/etc/systemd/system/内のファイルの編集も含まれます。
- systemctlコマンドを介してサービスを制御します。例えば、ユニットの起動、停止、再起動などです。
- journalctlでログをクエリし、特定のユニットからのリアルタイムまたは履歴出力を取得します。
- cgroupsを統合してリソース制限を設定します。例えば、サービスに対するCPU/メモリの制約などです。
- ソケットアクティベーションを有効にして、オンデマンドでサービスを起動し、リソースオーバーヘッドを削減します。
- OpenClawバイナリを指すExecStartを持つユニットファイルを作成することで、OpenClawをsystemdサービスとして扱います。
使用パターン
常にsudoを使用するか、rootとして昇格された権限でコマンドを実行してください。スクリプトでは、Pythonのsubprocess呼び出しやBashのshell execを使用してsystemctl/journalctlを呼び出します。ユニットファイルの作成には、ファイルを直接編集するか、systemd-analyzeで検証します。OpenClawと統合する場合、サービスユニットが正しいバイナリパスと環境変数を参照していることを確認してください。使用パターンは、まずサービスの状態を検出し、次にアクションを実行し、出力をログに記録するように構成します。cgroupsの場合、systemdをリロードする前にユニットファイルの[Service]セクションで制限を指定します。
一般的なコマンド/API
サービス管理にはsystemctlを使用します。例: サービスを開始するには systemctl start <unit>。ログには、出力を追跡するために journalctl -u <unit> -f を実行します。再起動するには、非ブロッキング操作のために systemctl restart <unit> --no-block を使用します。cgroupsの場合、systemctl status <unit> | grep CGroup で検査するか、ユニットファイルを介して設定します。ソケットアクティベーションの設定: ユニットファイルに Sockets= を追加し、systemctl start <socket-unit> を使用します。Bashでのコードスニペット:
#!/bin/bash
systemctl stop my-service
systemctl start my-service
echo "Service restarted"
Pythonでは、次のように使用します。
import subprocess
subprocess.run(['systemctl', 'status', 'my-service'])
OpenClawサービスの場合、次のようなユニットファイルを作成します。
[Unit]
Description=OpenClaw Service
[Service]
ExecStart=/usr/bin/openclaw --config /etc/openclaw/config.json
統合に関する注意点
cgroupsを統合するには、ユニットファイルの[Service]セクションに CPUQuota=50% のような行を追加し、systemctl daemon-reload を実行してユニットを再起動します。ソケットアクティベーションの場合、.socketユニットファイル(例: ListenStream=12345)を定義し、それをサービスユニットにリンクします。OpenClawをサービスとして管理する場合、ユニットファイルに環境変数を設定します。例: Environment="OPENCLAW_API_KEY=$SERVICE_API_KEY"。そして、$SERVICE_API_KEYがシェルまたはsystemd環境ファイルでexportによって設定されていることを確認してください。変更後には systemctl daemon-reload でsystemdをリロードします。systemctl list-units --type=service で既存のユニットを確認し、競合を避けてください。
エラー処理
常にコマンドの終了コードを確認してください。例えば、Bashでは if systemctl start <unit>; then echo "Success"; else echo "Failed: $?"; fi を使用します。Pythonでは、subprocess呼び出しをtry-exceptブロックで囲みます。try: subprocess.run([...], check=True) except subprocess.CalledProcessError as e: print(f"Error: {e.returncode}")。一般的なエラーには、「Failed to start unit」(権限または依存関係を確認)や「Unit not found」(systemctl list-units でユニット名を確認)があります。journalctlの場合、journalctl -u <unit> --since "1 hour ago" でログがない場合を処理し、出力を解析してエラーを探します。cgroupsが失敗した場合は、systemctl status <unit> で制限をデバッグし、cat /proc/cgroups でカーネルサポートを確認してください。
具体的な使用例
例1: OpenClawサービスを起動して監視します。まず、/etc/systemd/system/openclaw.service に次のような内容のユニットファイルを作成します。
[Unit]
Description=OpenClaw Daemon
[Service]
ExecStart=/usr/bin/openclaw
次に、systemctl daemon-reload; systemctl start openclaw; journalctl -u openclaw -f を実行して、サービスを起動し、ログを追跡します。
例2: cgroup制限付きでサービスを再起動します。ユニットファイルを編集して [Service] CPUQuota=30% を含め、systemctl daemon-reload; systemctl restart my-service を実行します。systemctl status my-service | grep CGroup でCPU制限が適用されていることを確認します。
グラフ関係
- 接続先: linux cluster (例: ファイル管理やプロセス制御など、他のLinuxスキルと依存関係を共有します)。
- タグによる関連: systemd (直接リンク)、services (例: コンテナまたはオーケストレーションスキルへ)、linux (広範なクラスタ連携)、units (リソース管理スキルへリンク)。
- 統合ポイント: cgroup (パフォーマンス監視ツールへ接続)、socket activation (ネットワーキングスキルに関連)。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
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).