LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-20-2003, 07:47 AM   #1
fiod
LQ Newbie
 
Registered: Sep 2003
Posts: 26

Rep: Reputation: 15
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,
 
Old 09-20-2003, 08:06 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
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

Last edited by kev82; 09-20-2003 at 08:08 AM.
 
Old 09-20-2003, 08:29 AM   #3
fiod
LQ Newbie
 
Registered: Sep 2003
Posts: 26

Original Poster
Rep: Reputation: 15
thank you.

worked perefectly.
 
Old 09-20-2003, 09:56 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,675
Blog Entries: 54

Rep: Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953
pgrep wget >/dev/null && echo "Is working" || echo "Aint working"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 05:19 AM
New to C++ help with simple script Fredstar Programming 9 08-08-2005 12:09 PM
Help on simple script granny Programming 2 02-11-2004 05:02 PM
Simple Script fiod Linux - General 2 09-08-2003 04:03 PM
Simple C Shell script is not so simple elconde Programming 2 09-17-2001 12:53 AM


All times are GMT -5. The time now is 04:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration