> For the complete documentation index, see [llms.txt](https://docs.insilicoterminal.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.insilicoterminal.com/documentation/terminal-cli/chaining.md).

# Chaining

Chain any commands by using

* the `;` operator for sequential processing, one after another. Note that the next command does not await the previous command to "finish" or succeed.
* the `&` operator for parallel processing of the chained commands at once.

While they are essentially the same you should use `;` around `sleep` commands. Generally it might be a semantic help for different use cases. Both can be used with or without spaces on either side, use to your liking.

For example:

`buy 1000$ btcusdt & buy 2000$ ethusdt`

You could think of it as "do this AND do that at once". While:

`buy 1000$; sleep 5s; buy 1000$ at -1%`   &#x20;

you could think of it as "do this, THEN wait 5s, THEN do that".

{% hint style="success" %}
Note that when you want to chain commands which are "dependant" on each other, latencies might vary and work against you. E.g. if you attempt to `buy 1000$  ; sell 100% at 1% reduce` the exchange might process your reduce order before your position has been opened. Best to incorporate a short sleep here.
{% endhint %}

#### Sleep

The `sleep` command introduce a timeout inside sequential command chains and allows for durational commands and ordering in the CLI. The syntax is: `sleep <duration>` where unit supports `ms`, `s`, `m` - seconds `s` are applied when the unit is omited. A max duration of 10min applies.\
Examples:&#x20;

`sleep 500`,    `sleep 1s`,    `sleep 2m`

#### Task Management

Every chained command using sleep (and repeat command) has an ID assigned which is a session-local rolling counter maintained by the CLI. The IDs are shown via: Console log, `tasks` command and the Activity component.

Inside the CLI the following commands are available for control:

```
tasks               # list active CLI tasks only (IDs + command string)
kill                # kill the most-recent CLI task
kill 3              # kill task ID 3
kill all            # kill every running CLI task
```

#### UI for tasks via Activity component

Use the Activity component to monitor ongoing durational chained tasks. You can manually cancel repeat tasks .
