LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   A Simple Script (https://www.linuxquestions.org/questions/linux-general-1/a-simple-script-94787/)

fiod 09-20-2003 06:47 AM

A Simple Script
 
Hi,

I am trying to write a simple script, that we be activated by CRON every hour, to check whether WGET is working or not.
If its not working - it should activate it.
What I have so far:

#!/bin/bash

ps ax > tempdata
grep -q wget tempdata

if [ $? -eq "0" ]
then
echo "Already Working"
else
wget -m .......
fi

rm -f tempdata

Anyone has a suggestion how to write this script, without creating a file? (TEMPDATA)
Simply writing "ps ax | grep wget" is not good, cuz grep will always find the process "grep wget"....

Thanks in Advance,

kev82 09-20-2003 07:06 AM

ps ax | awk '{print $5}' | grep wget

doesnt pick up 'grep wget' because the wget is in field 6, although it would be simpler to use pidof

fiod 09-20-2003 07:29 AM

thank you.

worked perefectly.

unSpawn 09-20-2003 08:56 PM

pgrep wget >/dev/null && echo "Is working" || echo "Aint working"


All times are GMT -5. The time now is 07:13 PM.