[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] script til at chekke om en process køre



Max Jensen wrote:
> Atte André Jensen skrev:
> 
>> Max Jensen wrote:
>> <snip>
> 
>> Kunne du være lidt mere præcis. Nøjagtig hvordan ser dit script ud,
>> hvad gør du for at køre det og hvilke fejl meddelelser får du?
> 
> mit script ser sådan ud.
> 
>   pid=""
>   pid='ps -ef | grep new.i686 | awk ' {print $2}''

Det er muligvis de forkerte abostroffer (eller mail har ændret dem) ?
brug $( cmd ) i i stedet for.

awk kan også søgning så grep er unødvendig.

pid=$(ps -ef | awk '/new.i686/ { print $2 } ' )

men denne vil jo også finde processen "grep new.i686"
(eller den med awk '/new.i686/' )
som måske ikke var det du ledte efter,
så søgningen selv skal også undtages:

pid=$(ps -ef | awk '/new.i686/ && ! /awk/ { print  } ' )

men hvorfor ikke bruge option  -C :

  ps -C new.i686    # (fuld navn på programmet, fuld path ikke nødvendigt)

eller endnu mindre, kun list pid's i output :
 ps -f -o pid -C new.i686

så

pid=$(ps --no-headers -o pid -C new.i686)


>   echo $pid
>   if [ "$pid"="" ]

her skal der vist et par spaces ind:

  if [ "$pid"  =  "" ]

>   then
>   echo "process not running"
>     else
>   echo service is ok
>   pid=""
>   fi
> 
> når jeg starter det ved at skrive ./check (når det virker havde jeg
> tænkt mig at det skulle køre ved hjælp af crontab)
> kommer følgende fejl:
>   line 3: {print: command not found
> 
>   process not running
> 
> Selv om processen køre som den skal skriver den "process not running"

ret ovenstående fejl så virker det.


#!/bin/sh

pid=$(ps --no-headers -o pid -C new.i686 )


echo $pid
if [ "$pid" = "" ]
then
   echo "process not running"
else
   echo service is ok
   pid=""
fi




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2009-10-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] *