The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" iBot UNIX and Linux RSS News 0 01-04-2008 12:00 PM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-19-2007 10:52 PM
grep to find content in between curly braces, "{" and "}," keshav_rk Shell Programming and Scripting 4 08-09-2007 07:14 PM
Pls correct the "if" syntax ganapati Shell Programming and Scripting 5 07-30-2006 11:07 PM
correct syntax for using "grep regex filename" ? yongho UNIX for Dummies Questions & Answers 2 06-13-2005 11:44 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-03-2001
Registered User
 

Join Date: Oct 2001
Posts: 1
correct use of "ps -ef | grep "?

I am trying to run a program which checks to see if a process is running. If the process is not running, I want to start (re-start) the process. If the process is still (already) running, do nothing.

Here is the process; it starts manually:
$java Validation


here is my code to see if it is still running:
logfile1=/usr/test/file1.log
logfile2=/usr/test/file2.log

if ( ps -ef | grep Validation )
then
date>>$logfile1
echo val program already running>>$logfile1
else
date>$logfile2
echo val program needs restarting>>$logfile2
/usr/test/java Validation>>$logfile2
fi


PROBLEM:
When the Validation program stops (I stopped it manually), and the above code runs, it still thinks the process is running.
When I type "ps -ef | grep Validation" at the command line, it returns:
grep Validation

This is nothing more than the command I just entered. I guess this is why the above code still thinks my java program is running, but it is not.

When I execute "ps -ef | grep Validation" from the command line when the Validation program is running, I get:
/usr/test/java Validation
grep Validation

Why I am getting "grep Validation" returned?
How can I stop from getting "grep Validation" returned?

Thank you so much!
Forum Sponsor
  #2  
Old 10-03-2001
Neo's Avatar
Neo Neo is offline
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 4,441
ps -ef | grep Validation | grep -v grep
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0