Wowza Community

Keep Server Alive with Cron Job

Despite my best efforts, the server still dies sometimes and I am in a random place trying to ssh into the server to restart it on my cell phone after customers start calling… I tried using google to track down a script that would do the following

Every 5 min execute:

sudo /etc/init.d/WowzaMediaServer status

Then it would grep for “started” and if it isn’t found would execute:

sudo /etc/init.d/WowzaMediaServer start

I am not sure how to setup the script + it is going to ask for a password to use the sudo command.

Anybody able to give me a hand? Seems like a nice script that many people should have on hand anyway.

i think it would be better to find why wowza stops and fix that :slight_smile:

but from memory you could use something like this

create a file called wowza.sh and perhaps put it in /user/local/sbin

#!/bin/bash
# check Wowza
ps -ef | grep -v grep | grep WowzaMediaServer
# if not found - equals to 1, start it
if [ $? -eq 1 ]
then
/etc/init.d/WowzaMediaServer start
else
echo "eq 0 - wowza running - do nothing"
fi

and then add a cron entry like this

*/5 * * * * /usr/local/sbin/wowza.sh

Zip up conf, logs and bin and send to support@wowza.com with a reference to this thread. Are you running Wowza as a system service or are you starting it using ./startup.sh? If ./startup.sh that could explain why it is stopping. The Quick Start guide describes how to start as system service.

Charlie

I guess I would focus on why the server is stopping so often. For most folks it runs 24/7/365.

Charlie

Awesome Mr-Webcam guy :slight_smile:

I would love to find more about how to identify the reason for the crashing but it doesn’t happen more than every few weeks and no error is generated so not sure what to do other than try to restart it till I get it on another server.

Usually I run the command with the sudo command llike:

sudo /etc/init.d/WowzaMediaServer start

I get prompted for a password, anyway of having the password bypassed or entered with the script?

Ok then give me a suggestion. Why would the server die when it is only supporting around 120-150 streams and how can I find out if the server leaves no errors?

I have been through all the applicable perfomance tuning tips and upgraded to the latest versions of Wowza and Java.

If I can’t keep the server running, I just want it to restart automatically.

Tip, to bypass the password I found a way with the command visudo

Code:

cron ALL=NOPASSWD: /etc/init.d/WowzaMediaServer

which would let the cron user run /etc/init.d/WozaMediaServer as root without a password.