---
title: spawn
---

# spawn

Dynamically create child processes from parent services.

:::warning Deprecated
`sysg spawn` is deprecated. Use `sysg start --parent-pid <pid> --name <name> -- <command...>`.
:::

```sh
$ sysg spawn --name worker_1 -- python worker.py
```

## Options

| Short | Long | Description |
|-------|------|-------------|
| `-` | `--name` | Required. Unique identifier for spawned process |
| `-` | `--ttl` | Time-to-live in seconds (optional) |
| `-` | `--parent-pid` | Parent process ID (defaults to caller's parent PID if not specified) |
| `-` | `--sys` | Opt into privileged system mode. Requires running as root |
| `-` | `--log-level` | Override the logging verbosity for the spawned process |

## Examples

### Preferred replacement with `start`

```sh
$ sysg start --parent-pid 12345 --name worker_1 -- python worker.py
$ 12345  # Returns PID
```

### Spawn a worker process

```sh
$ sysg spawn --name worker_1 -- python worker.py
$ 12345  # Returns PID
```

### Spawn with time limit

Process automatically terminates after 1 hour:

```sh
$ sysg spawn --name temp_worker \
  --ttl 3600 \
  -- ./process.sh
```

### Spawn with parent PID tracking

```sh
$ sysg spawn --name api_worker \
  --parent-pid 12345 \
  -- node worker.js
```

## Requirements

Parent service must be configured with:

```yaml
services:
  orchestrator:
    command: "porki --role orchestrator --instructions instructions/INSTRUCTIONS.md"
    spawn:
      mode: dynamic
      limit: 10
```

The parent can then spawn up to 10 child processes dynamically.

## See also

- [Spawn configuration](/how-it-works/configuration#spawn-settings)
- [`status`](/how-it-works/commands/status) - View spawned processes
