2

I currently use an application called MxEasy on my linux servers to display video from a couple of IP cameras. The software is rather buggy and crashes occasionally. I've wrote a script that checks to see if the application is running and if its not... it launches the application.

I've tried adding this line to my crontab to have it run the script. It's running the script but not launching MxEasy. Any thing I'm over looking?

0,15,30,45,50 * * * * root  export DISPLAY=:0 && /etc/cron.hourly/MxEasyCheck.sh 

BTW Ubuntu Server 12.04 is the OS

Here is MxEasyCheck.sh

MXEASY=$(ps -A | grep -w MxEasy)

if ! [ -n "$MXEASY" ] ; then
    /home/emuser/bin/MxEasy/startMxEasy.sh &
    exit
fi

Here is my crontab

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
0  *    * * *   root    /etc/cron.hourly/rsynccheck.sh
0,15,30,45,50 * * * * root  export DISPLAY=:0 && /etc/cron.hourly/MxEasyCheck.sh 
#
Matthew
  • 175
  • 1
    Error messages (likely sent to root mailbox)? Are you sure MxEasyCheck.sh is set to be executable as root? What does MxEasyCheck.sh look like? What about providing a FULL ip address with the DISPLAY variable? Without any of this type of information, nobody will be able to help you. – mdpc Nov 09 '12 at 18:20
  • Can I catch a break around here? I ether get told I'm posting too much information or too little...Why would I need to provide a IP address with the display command? the program is being launch on the local machine.. Permissions are set on MxEasyCheck.sh to chmod 754 – Matthew Nov 09 '12 at 18:50
  • 1
    I'm saying to try putting the full IP address in the assignment and trying that. Without seeing the script, about the only comment we might make is that what happens if the service the scripting calls gets called again when active? Other than that, there is nothing we could tell you. You have not indicated that you have searched the various error logs out there. – mdpc Nov 09 '12 at 19:00
  • Where does this entry come from? If it is in the root crontab, (ie. using crontab -e), then it has a syntax error by including root in the line. – mdpc Nov 09 '12 at 19:01
  • Root is included in all the other entries.. Also I've checked the syslog and script is being executed. "Nov 9 11:00:01 EMserver1 CRON[10533]: (root) CMD ( export DISPLAY=:0 && /etc/cron.hourly/MxEasyCheck.sh )" – Matthew Nov 09 '12 at 19:10
  • What other logs should I look into? – Matthew Nov 09 '12 at 19:10
  • check the root mailbox for the results of this cron run. – mdpc Nov 09 '12 at 19:11

3 Answers3

4

Rather than check every few minutes, write a loop that relaunches the program when it terminates abnormally. But don't roll your own, there are plenty of existing programs to do that. See Ensure a process is always running

2

Consider to let your app to be spawn by init... see init(8) - keep things simple

0

Use the Bellow mention cell script for Creating the Watcher Blog.

bin=WatcherName echo "Today Date is=" date pid=pgrep -f javaProcess.jar

if [ $pid ] then echo $bin is Already Runnning PID: $pid else echo $bin is not running. Going to run: cd /home/Apps/path/ sh run.sh fi