LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash Scripting Question (https://www.linuxquestions.org/questions/linux-newbie-8/bash-scripting-question-381133/)

fiod 11-08-2005 11:17 AM

Bash Scripting Question
 
Hey,

I want to write a simple script that checks to see if aMule is running, and if it is not running - activate the program.

My main directions are using grep somehow, though simply typing "ps ax | grep amule" always gives some answer (even if amule is not running).

I'd appreciate any help.

Tnx,
fiod

Dtsazza 11-08-2005 11:44 AM

What answer does it give you if it's not running?

nx5000 11-08-2005 11:46 AM

Code:

[ `pidof -s amule` == "" ] && amule

When making
Code:

ps ax | grep pattern
, you always get the line "grep pattern" because "grep pattern" contains "pattern", so
Code:

ps ax | grep amule | grep -v grep
could do the trick

fiod 11-15-2005 03:53 AM

Thank You

linmix 11-19-2005 05:09 AM

would you mind posting your resulting script? I'd like to have a look at it and see if I can adapt it in some way to check the kppp demon is running. It's crashing on me every 1 or 2 days and it would be nice to be able to keep a tab on it, close all kppp related threads , restart and reconnect automatically (as opposed to finding out kppp crashed 5 minutes after I went to bed while trying to do a 'yum update')


All times are GMT -5. The time now is 11:55 PM.