# Script to test the module service

Older operating systems may not have a service management system (systemd/supervisor). In such cases, a script that checks the status of the service and restarts it upon errors may help.

Create a script file (for example /etc/scripts/autostart\_itgrix\_bx.sh or /etc/scripts/autostart\_itgrix\_kmo.sh), and add the following code to it:

For Bitrix24 module:

```bash
#!/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  
```

For Kmo module:

```bash
#!/bin/bash

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

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

Add a task to the cron scheduler to run the script once a minute:

```
crontab -e
```

For Bitrix24:

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

For Kmo:

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


---

# 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.com/for-admins/script-to-test-the-module-service.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.
