# ジョブ: 最小構成 (Linux)

**想定読者:** Linuxエンドポイントへカスタム実行ファイルをデプロイする統合担当者。

本例は[ジョブ: 最小構成 (Windows)](/keeperpam/jp/endpoint-privilege-manager/integrations/examples/job-minimal-windows.md) のLinux向け版です。ジョブの骨子は同じで、違いはバイナリのパス、`osFilter`、および`.exe` 拡張子がない点です。異種OSが混在するフリートでは、Windows版およびmacOS版とあわせて3種類を用意し、すべてデプロイしてください。

## ジョブのJSON <a href="#the-job-json" id="the-job-json"></a>

```json
{
  "id": "my-tool",
  "name": "My Tool",
  "description": "Runs MyTool on a 60-minute interval.",
  "enabled": true,

  "schedule": {
    "intervalMinutes": 60
  },

  "osFilter": {
    "windows": false,
    "linux": true,
    "macOS": false
  },

  "mqttTopics": {
    "allowedPublications": ["KeeperLogger"],
    "allowedSubscriptions": []
  },

  "parameters": [],

  "tasks": [
    {
      "id": "run-tool",
      "name": "Run tool",
      "ExecutionType": "Service",
      "command": "mytool",
      "executablePath": "/opt/KeeperPrivilegeManager/Jobs/bin/mytool/mytool",
      "arguments": "--keeper-api-base={KeeperApiBaseUrl}",
      "timeoutSeconds": 3600,
      "continueOnFailure": false,
      "scriptType": "Auto"
    }
  ]
}
```

## 変更する箇所 <a href="#what-to-change" id="what-to-change"></a>

<table><thead><tr><th width="244.6666259765625">フィールド</th><th>内容</th></tr></thead><tbody><tr><td><code>id</code></td><td>本ジョブを一意に識別する文字列。ハイフンを使い、アンダースコアは使いません。ファイル名は <code>id</code> と一致させます (例: <code>"id": "my-tool"</code> のときは <code>my-tool.json</code>)。異種OSが混在するフリートへ展開する場合は、Windows版およびmacOS版と同じIDに揃えてください。</td></tr><tr><td><code>name</code></td><td>ログや管理画面に表示する名称</td></tr><tr><td><code>tasks[0].command</code></td><td>実行ファイル名。Linuxでは多くの場合小文字。エージェントは <code>Jobs/bin/{command}/{command}</code> を自動解決</td></tr><tr><td><code>tasks[0].executablePath</code></td><td>実行ファイルのフルパス。Linuxでのエージェントのデフォルトインストールルートは <code>/opt/KeeperPrivilegeManager</code>。別パスで展開している場合は管理者へ確認</td></tr><tr><td><code>tasks[0].arguments</code></td><td>実行ファイルが受け付けるフラグ。<code>{KeeperApiBaseUrl}</code> は削除せず残す。エージェントが実行時にローカルのHTTPS APIベースURLへ差し替え</td></tr><tr><td><code>schedule.intervalMinutes</code></td><td>実行間隔 (分)</td></tr><tr><td><code>tasks[0].timeoutSeconds</code></td><td>エージェントがタスクを強制終了するまでの最大実行時間</td></tr></tbody></table>

**バイナリ名:** Linuxの実行ファイルに `.exe` はありません。`command` と `executablePath` の両方に、拡張子なしの名前を使います。慣例として名前は小文字 (`mytool` など) が多いですが、エージェントは指定した名前で解決します。

**ファイルのパーミッション:** バイナリはエージェントのサービスアカウントから実行可能である必要があります。デプロイ後に以下のコマンドを実行します。

```bash
chmod +x /opt/KeeperPrivilegeManager/Jobs/bin/mytool/mytool
```

エージェントが特定ユーザーで動いている場合 (管理者に確認)、そのユーザーがバイナリおよび親フォルダに対する読み取りと実行権限を持つようにしてください。

**`osFilter` と検証:** `linux` だけが `true` のため、WindowsおよびmacOS上のエージェントは本ジョブをスキップします。ジョブの `osFilter` が現在のOSと一致しない場合、バリデータはバイナリ存在チェックも行いません。そのため、Windowsホストから登録しても、Linux用のパスがディスク上にあるかどうかは検証されません。

**Linuxでのプロセス信頼:** Linuxではエージェントのプロセス信頼は、主としてジョブランナーがバイナリを起動した事実に基づきます。証明書チェックの経路を避けるため、手動起動ではなくジョブタスクから常に起動してください。詳細はカスタムジョブ統合ガイドの[コード署名とプロセス信頼](/keeperpam/jp/endpoint-privilege-manager/integrations/custom-job-guide.md#code-signing-and-process-trust)をご参照ください。

## デプロイ前に <a href="#before-you-deploy" id="before-you-deploy"></a>

1. **先にバイナリをデプロイする:** `POST /api/Jobs` の呼び出し前に、エンドポイントの `executablePath` にバイナリを配置します。バリデータは呼び出し時点で存在を確認します。
2. **実行権限を付与する。** コピー後にバイナリに対して `chmod +x` を実行します。
3. **インストールルートを確認する:** `/opt/KeeperPrivilegeManager` がLinuxでの一般的なデフォルトです。デプロイ前に管理者へ確認してください。
4. **ファイル名は `id` と一致させる:** `"id"` が `"my-tool"` なら `my-tool.json` として保存します。

## デプロイ <a href="#deploy" id="deploy"></a>

保存前に検証します。

```bash
curl -s -X POST https://127.0.0.1:6889/api/Jobs/validate \
  --cert /path/to/client.pem \
  --key /path/to/client.key \
  --cacert /path/to/ca.pem \
  -H "Content-Type: application/json" \
  -d @my-tool.json
```

ジョブを作成します。

```bash
curl -s -X POST https://127.0.0.1:6889/api/Jobs \
  --cert /path/to/client.pem \
  --key /path/to/client.key \
  --cacert /path/to/ca.pem \
  -H "Content-Type: application/json" \
  -d @my-tool.json
```

手動トリガーで確認します。

```bash
curl -s -X POST https://127.0.0.1:6889/api/Jobs/my-tool/trigger \
  --cert /path/to/client.pem \
  --key /path/to/client.key \
  --cacert /path/to/ca.pem \
  -H "Content-Type: application/json" \
  -d "{}"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeperpam/jp/endpoint-privilege-manager/integrations/examples/job-minimal-linux.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
