Mailinglist Archive: opensuse (4570 mails)

< Previous Next >
Re: [SLE] Script to check if an application is running
  • From: Yogich <yogich@xxxxxxxxxx>
  • Date: Thu, 17 Nov 2005 15:03:30 +0000 (UTC)
  • Message-id: <200511170903.15923.yogich@xxxxxxxxxx>
On Thursday 17 November 2005 01:39, Albert wrote:
> Hi All,
>
>
>
> I want to write a bash script which can be executed by cron every minute to
> check if an application is running. If it is not running the script should
> start it again.
>
>
>
> What I normally would do to check if it is running is execute:
>
>
>
> # ps aux | grep App
>
> root 7479 15.4 0.7 21300 7816 pts/1 Sl 06:34 0:00
> /usr/local/bin/App
>
> root 7495 0.0 0.0 2880 700 pts/1 R+ 06:34 0:00 grep App
>
>
>
> Is there a way of doing this? If it is, would it be reliable to use a bash
> script and cron for checking if the application is running?
>
>
>
> TIA
>
>
>
> Albert
Here's one I used for checking my internet connection... perhaps you can
modify it for your needs. Someone on this list was kind enough to share it
with me about a year ago, or so. Cannot remember the name, unfortunately.

How to stay connectd to internet:

#!/bin/bash
#
# Script to check if ADSL is disconnected & try reconnecting
#
result=$(cinternet -i dsl0 -s | grep disconnect)
#Checks the status of device dsl0 for the word 'disconnect' and stores the
#result in a variable called 'result'
if [ -n "$result" ]
#Test to see if the value is not NULL
then
#OK the interface is down
cinternet -i dsl0 -A
#Start the interface.
sleep 10
else
#The interface is up - Just exit
exit 0
fi
____________________ EOF ______________________

HTH...
--
...Yogich

< Previous Next >
Follow Ups
References