# systemd свой скрипт запуска

файлы \*.service расположены по пути **/lib/systemd/system**

<details>

<summary>/lib/systemd/system/template.service</summary>

```
[Unit]
Description=Custom start script            #описание
ConditionFileIsExecutable=/etc/01-start    #является ли файл исполняемым
After=network.target

[Service]
Type=simple
ExecStart=/etc/01-start start            #запуск
TimeoutSec=0                             #можно указать таймаут для запуска

[Install]
WantedBy=default.target
```

</details>

после создать файл скрипта по указанному пути

<details>

<summary>/etc/01-start</summary>

```
#!/bin/sh -e

#здесь текст скрипта

exit 0
```

</details>

после этого нужно сделать файл исполняемым

```
sudo chmod +x /etc/01-start
```

перезагрузить процесс systemd, чтобы учесть вновь созданный \*.service

```
sudo systemctl daemon-reload
```

включить созданную службу для запуска после перезагрузки

```
sudo systemctl enable template.service
```


---

# 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://visman.gitbook.io/os/linux/systemd-svoi-skript-zapuska.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.
