LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 06: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, 07:06 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
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 07:08 AM.
 
Old 09-20-2003, 07:29 AM   #3
fiod
LQ Newbie
 
Registered: Sep 2003
Posts: 26

Original Poster
Rep: Reputation: 15
thank you.

worked perefectly.
 
Old 09-20-2003, 08:56 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

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


Reply



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 04:19 AM
New to C++ help with simple script Fredstar Programming 9 08-08-2005 11:09 AM
Help on simple script granny Programming 2 02-11-2004 04:02 PM
Simple Script fiod Linux - General 2 09-08-2003 03:03 PM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:59 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
Open Source Consulting | Domain Registration