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 03:00 PM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
grep to find content in between curly braces, "{" and "}," keshav_rk Shell Programming and Scripting 4 08-09-2007 11:14 PM
Pls correct the "if" syntax ganapati Shell Programming and Scripting 5 07-31-2006 03:07 AM
correct syntax for using "grep regex filename" ? yongho UNIX for Dummies Questions & Answers 2 06-13-2005 03:44 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-03-2001
mulligm mulligm is offline
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!
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:56 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0