# Services

CrushClient can run in the background from the moment the machine starts, with nobody logged in. That is what you want for a [managed agent](Managed-Agent.md), for [schedules](Schedules.md) on a server, or for a CrushClient you use from a browser ([Remote access](Remote-Access.md)).

The service runs `CrushTunnel.jar`, CrushClient's engine. It reads the `prefs.XML` in the same folder as the jar, so set CrushClient up first and copy your settings there.

## Windows

1. Set CrushClient up the way you want it: managed servers, bookmarks, schedules, the agent password.
2. Put `CrushTunnel.jar` in a folder that will stay, and copy the settings next to it:
   - `prefs.XML` from the settings folder, `%LOCALAPPDATA%\CrushClient\`;
   - your bookmarks and schedules are in `CrushClientUser_prefs.XML` in the same folder ([Files and folders](Files-and-Folders.md)).
3. In an elevated Command Prompt in that folder, start the prompt and install the service:

   ```
   java -jar CrushTunnel.jar
   service client
   quit
   ```

4. Check it in the Windows **Services** console. The service is named **CrushClient**.

To remove it:

```
java -jar CrushTunnel.jar
service remove client
quit
```

To change the settings later, remove the service, change and copy the settings again, and install it again.

### More than one, or another name

Add `_` and a name to run several services side by side, each from its own folder:

```
service client_-Warehouse
service remove client_-Warehouse
```

### The other apps

The same command installs the engines of the other apps as Windows services. Each has its own page:

| Command | Installs | See |
|---|---|---|
| `service sync` | CrushSync without its tray icon | [CrushSync](../CrushSync/Service-Mode.md) |
| `service tunnel <protocol> <host> <port> <user> <password>` | an always-on tunnel | [CrushTunnel](../CrushTunnel/Always-On.md) |

`service remove sync` and `service remove tunnel` remove them.

## Linux and macOS

Start the engine without a window from your own systemd unit, launchd job or init script:

```
java -Djava.awt.headless=true -cp CrushTunnel.jar com.crushftp.client.AgentUI
```

It reads `prefs.XML` from the folder it is started in and answers on port 33333. Keep the folder and its files readable only by the user it runs as: they hold the encrypted passwords of your bookmarks.

## Things to know

- A service has no window. Use it from a browser: [Remote access](Remote-Access.md).
- A service cannot answer [trust questions](Trust-Prompts.md). Connect to each server once in the window and choose **Trust and remember**, then copy `known_hosts` and `cert_pins.txt` from the settings folder next to the jar as well.
