# `Owl.Task`
[🔗](https://github.com/fuelen/owl/blob/v0.13.1/lib/owl/task.ex#L1)

Runs a task using the internal supervision tree.

# `run`

```elixir
@spec run((-&gt; result)) :: {:ok, result} | {:exit, term()} when result: any()
```

Runs a function as a task under the supervision tree.

This is useful when you need a graceful shutdown in simple scripts where Owl is installed
using `Mix.install/2`.

## Example

    # content of ping.exs file, run as `elixir --no-halt ping.exs`
    Mix.install([:owl])

    Owl.Task.run(fn ->
      Owl.System.daemon_cmd("ping", ["8.8.8.8"], fn ->
        Process.sleep(3000)
        2 + 2
      end)
    end)

    System.stop()

---

*Consult [api-reference.md](api-reference.md) for complete listing*
