Strange behaviour with ps and inverse quotes on POWER5 and AIX 5.3TL6 - Aix

This is a discussion on Strange behaviour with ps and inverse quotes on POWER5 and AIX 5.3TL6 - Aix ; Hi, anyone seen this and have any ideas? I have created a script called /tmp/chris_script that looks like this #!/bin/ksh RET=`ps -ef | grep root | grep chris_script | grep -v grep` echo $RET When I run the script on ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Strange behaviour with ps and inverse quotes on POWER5 and AIX 5.3TL6

  1. Strange behaviour with ps and inverse quotes on POWER5 and AIX 5.3TL6

    Hi,

    anyone seen this and have any ideas?

    I have created a script called /tmp/chris_script that looks like this


    #!/bin/ksh

    RET=`ps -ef | grep root | grep chris_script | grep -v grep`
    echo $RET




    When I run the script on a P5 box the RET string finds two processes
    (it should only find one - me runnig the script in the first place).
    The second is a child of the first and the first is a child of my
    shell

    If I run the script in an infinite while loop

    while :
    do
    /tmp/chris_script
    done

    then it finds anything from 1 to 5 processes

    If I run the script on a P4 box with the same version of AIX it only
    ever finds one process.


    Any ideas?

  2. Re: Strange behaviour with ps and inverse quotes on POWER5 and AIX5.3 TL6

    On 20 Feb, 15:53, Chris S wrote:
    > Hi,
    >
    > anyone seen this and have any ideas?
    >
    > I have created a script called /tmp/chris_script that looks like this
    >
    > #!/bin/ksh
    >
    > RET=`ps -ef | grep root | grep chris_script | grep -v grep`
    > echo $RET
    >
    > When I run the script on a P5 box the RET string finds two processes
    > (it should only find one - me runnig the script in the first place).
    > The second is a child of the first and the first is a child of my
    > shell
    >
    > If I run the script in an infinite while loop
    >
    > while :
    > do
    > /tmp/chris_script
    > done
    >
    > then it finds anything from 1 to 5 processes
    >
    > If I run the script on a P4 box with the same version of AIX it only
    > ever finds one process.
    >
    > Any ideas?


    Remember that you will generate five separate processes when you run
    you script:

    chris_script
    ps -ef
    grep root
    grep chris_script
    grep -v grep

    But you don't get them straight away - first a fork() creates a copy
    of the original process image, then the exce() replaces that image -
    so it looks like the POWER5 server is so fast that this process is
    becoming visible to you.

  3. Re: Strange behaviour with ps and inverse quotes on POWER5 and AIX5.3 TL6

    >
    > If I run the script on a P4 box with the same version of AIX it only
    > ever finds one process.
    >
    > Any ideas?


    You could always try simplifying it by cutting down on the number of
    spawned processes by using only one grep like:

    RET=$(ps -ef | grep -E "[r]oot.*chris_script")

    Which should return the exact same result, the [r] part will eliminate
    the grep process itself from being displayed.

    regards,
    Jesper James

+ Reply to Thread