Script to test the module service

Older operating systems may not have a service management system (systemd/supervisor), in such cases a script to check the status of the service and restart it, if it fails 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 module in Bitrix24
#!/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 module in Kmo
#!/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

Let's add a task to the cron scheduler to run the script once a minute:

// in the console on the server
crontab -e

For Bitrix24

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

For Kmo

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

Last updated