# Скрипт для проверки работы службы модуля

В старых операционных системах может отсутствовать система управления службами (systemd/supervisor), в таких случаях может помочь скрипт для проверки статуса службы и перезапуска если служба не работает.

Создадим файл скрипта (например /etc/scripts/autostart\_itgrix\_bx.sh или /etc/scripts/autostart\_itgrix\_amo.sh), и добавим туда следующий код:

```bash
// Для модуля в Битрикс24
#!/bin/bash

# module itgrix
PGREP="/usr/bin/pgrep -x"
RESTART_itgrix_bx="/etc/init.d/itgrix_bx restart"
itgrix="itgrix_bx"

$PGREP ${itgrix}
if [ $? -ne 0 ]; then
$RESTART_itgrix_bx
fi  
```

```bash
// Для модуля в Amo
#!/bin/bash

# module itgrix
PGREP="/usr/bin/pgrep -x"
RESTART_itgrix_amo="/etc/init.d/itgrix_amo restart"
itgrix="itgrix_amo"

$PGREP ${itgrix}
if [ $? -ne 0 ]; then
$RESTART_itgrix_amo
fi
```

Добавим в планировщик cron задачу по запуску скрипта раз в минуту:

```
// в консоли на сервере
crontab -e
```

Для Битрикс24

```
*/1 * * * * /etc/scripts/autostart_itgrix_bx.sh
```

Для Amo

<pre><code><strong>*/1 * * * * /etc/scripts/autostart_itgrix_amo.sh
</strong></code></pre>


---

# 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://docs.itgrix.ru/for-admins/skript-dlya-proverki-raboty-sluzhby-modulya.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.
