Following script monitors RMTP port, which indicates if Red5 is running or not
if (netstat -na | grep -q :1935) ; then
echo “Red5 running.”
If RMTP is open for connection nothing is done, else the script tries to start Red5 server by executing the red5.sh startup script.
so save the above script in red5 folder say /usr/local/red5/cron.sh
now we need to add a cron job to run the cron.sh at specified intervals, e.g. we will run it every 2 mins.
edit cron jobs with following command
now add following line to the cron jobs
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,59 * * * * /usr/local/red5/cron.sh & >/dev/null 2>&1
The above setup will monitor red5 every two minute , if server is not running it will start the server.