[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

RE: [TEKNIK] number of me - script problem



> Hejsa,
>   På solaris og AIX bruger jeg flg. lille kode-stump:
> 
> #!/bin/bash
> 
> NUM_OF_ME=$(ps -ef | grep num_of_me.sh |wc -l )
> echo $NUM_OF_ME
> 
> if [[ $NUM_OF_ME -gt 1 ]] ; then echo already running ; exit ; fi
> 
> [...]
> 
> 
> Men under linux er NUM_OF_ME lig 3, selvom der ikke kører andre kopier
> af scriptet.
> Hvad sker der lige og hvad kan det bedst løses, så det virker ens på
> alle unix-platforme ?
> 
> Hilsen
> Martin
> 


Du mangler en 'grep -v grep'

Ellers tæller den den grep med.


Eksempel:

ps -ef | grep bash
oracle   21097 21096  0 Apr12 pts/1    00:00:00 -bash
wrk      29909 29908  0 Apr12 pts/0    00:00:00 -bash
oracle   13818 13817  0 10:06 pts/2    00:00:00 -bash
wrk      16961 29909  0 10:33 pts/0    00:00:00 grep bash



ps -ef | grep bash | grep -v grep
oracle   21097 21096  0 Apr12 pts/1    00:00:00 -bash
wrk      29909 29908  0 Apr12 pts/0    00:00:00 -bash
oracle   13818 13817  0 10:06 pts/2    00:00:00 -bash

Med venlig hilsen / Regards

Frank Larsen
Kimik IT A/S
PO Box 740
3900 Nuuk
Greenland
Mail : sslug@sslug
Phone: +299 34 20 00
Fax  : +299 34 20 01


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2010-05-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *