[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



Martin Møller Skarbiniks Pedersen skrev:
2010/4/14 Erling A. Jacobsen <sslug@sslug>:
On Wed, 2010-04-14 at 14:15 +0200, Martin Møller Skarbiniks Pedersen
wrote:
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 ?
Det har formentlig ikke så meget at gøre med linux kontra ikke-linux,
men mere med at du også tæller grep processen med.

Jeg plejer altid at tilføje en "| grep -v grep" efter den første grep,
så passer pengene. Det kan sikkert også gøres mere sofistikeret.

Erling


Problemet er nok at $( ... ) giver en ekstra num_of_me.sh process på
linux men ikke AIX.

!/bin/bash

NUM_OF_ME=$({ps -ef | grep num_of_me.sh | grep -v grep | wc -l)
echo $NUM_OF_ME

if [[ $NUM_OF_ME -gt 1 ]] ; then echo already running ; exit ; fi


Prøv med :

NUM_OF_ME=`ps -ef | grep [n]um_of_me.sh | wc -l`
echo $NUM_OF_ME


if [[ $NUM_OF_ME -gt 1 ]] ; then echo already running ; exit ; fi



Med venlig hilsen

Martin Ahrentsen
Rødkælkevej 53, Hadbjerg
8370 Hadsten
25241017




 
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] *