Selasa, 28 April 2015

Note Vi - Check if App is Running in Terminal

For example :
name of our application : myApp
location of our application : /home/binaryvi/Desktop/App

I try check app is running or not using terminal in ubuntu. I use shell script. Here we go:

#!/bin/bash

if ps aux | grep "[m]yApp" > /dev/null
then
   echo "Running"
else
  echo "Stopped"
  export DISPLAY=::0.0
fi


If app is stopped, i want run the app. This is the code:

#!/bin/bash

if ps aux | grep "[m]yApp" > /dev/null
then
   echo "Running"
else
  echo "Stopped"
  export DISPLAY=::0.0

  /home/binaryvi/Desktop/App/myApp&
fi

Tidak ada komentar:

Posting Komentar