ggodw000 wrote:
Code:
count=`ps -ef | grep <script1> | wc -l`
This always going to be larger than 0, because grep itself is included in ps output. (btw the flag "f" makes no sense here.)
Code:
$ ps -ef | grep something
bzt 780842 147715 0 13:44 pts/0 00:00:00 grep something
This trick I've learned from an old UNIX guru:
Code:
$ ps -ef | grep [s]omething
This will list all processes containing "something" except the grep
The reason is, the command will be "grep [s]omething", however [] is replaced by the shell, and "grep something" will actually be executed, that doesn't match "[s]omething".
Btw, "wait" is a much better solution, I agree.
Cheers,
bzt