Monitor Service Port if Down execute a Bash Script

#!/bin/bash

HOST_NAME="127.0.0.1"
HOST_PORT="1656"

if ( (exec 3<>/dev/tcp/${HOST_NAME}/${HOST_PORT}) 2> /dev/null); then
echo -e "PORT: ${HOST_PORT} | ON"
else
cd /home/rumi/my-app/ && `node service.js`
fi

exit;
Share

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.