![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#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
|
||||
|
||||
|
ps -ef | grep Validation | grep -v grep
|
||||
| Google The UNIX and Linux Forums |