# 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
```
