Script to check if mysql replica (slave) is running:

#!/bin/sh

SLAVE_IS_RUNNING=$(/usr/local/bin/mysql -e "SHOW SLAVE STATUS\G" | grep Slave_SQL_Running: | awk '{print $2}')

if [ "$SLAVE_IS_RUNNING" != "Yes" ]
then
   # your options here
   /usr/local/bin/mysql -e "STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;"
fi

The username and password can be stored in a .my.cnf file, for example in /root/.my.cnf:

[client]
user=dbadmin
password=secret