Mailinglist Archive: opensuse (4570 mails)
| < Previous | Next > |
Re: [SLE] Script to check if an application is running
- From: Randall R Schulz <rschulz@xxxxxxxxx>
- Date: Thu, 17 Nov 2005 08:05:29 +0000 (UTC)
- Message-id: <200511170005.25181.rschulz@xxxxxxxxx>
Albert,
On Wednesday 16 November 2005 23: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
Keep in mind that such a command will return the ps output line for the
grep itself, unless you use a pattern that is not self-recognizing.
> 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?
The better way to get what you want is the pidof(8) command. Check it
out and you'll be able to do what you want, I think.
> Albert
Randall Schulz
On Wednesday 16 November 2005 23: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
Keep in mind that such a command will return the ps output line for the
grep itself, unless you use a pattern that is not self-recognizing.
> 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?
The better way to get what you want is the pidof(8) command. Check it
out and you'll be able to do what you want, I think.
> Albert
Randall Schulz
| < Previous | Next > |