when x process isn't running... do something

Discussion in 'Python' started by Bart Nessux, Jan 23, 2004.

  1. Bart Nessux

    Bart Nessux Guest

    Howdy,

    I'm trying to time how long it takes dd to run on a G5, versus how long
    it takes to run on a G4 (PATA vs. SATA). Both sytems have Mac OS X
    10.3.2 and Python 2.3. Could someone demonstrate how I might use Python
    to monitor for the presense of a process and to do something (in this
    case send an email which I know how to do) as soon as that process is no
    longer present? Any suggestions on how to monitor? Call top every 5 secs
    and read it's output searching for 'dd'???

    TIA,
    Bart
     
    Bart Nessux, Jan 23, 2004
    #1
    1. Advertising

  2. Bart Nessux

    Bart Nessux Guest

    Bart Nessux wrote:
    > Howdy,
    >
    > I'm trying to time how long it takes dd to run on a G5, versus how long
    > it takes to run on a G4 (PATA vs. SATA). Both sytems have Mac OS X
    > 10.3.2 and Python 2.3. Could someone demonstrate how I might use Python
    > to monitor for the presense of a process and to do something (in this
    > case send an email which I know how to do) as soon as that process is no
    > longer present? Any suggestions on how to monitor? Call top every 5 secs
    > and read it's output searching for 'dd'???
    >
    > TIA,
    > Bart
    >


    I forgot to mention the fact that I already know when the process began.
    All I need to know is when it ends and then I can calculate the part in
    between those two points.
     
    Bart Nessux, Jan 23, 2004
    #2
    1. Advertising

  3. Bart Nessux wrote:

    > Bart Nessux wrote:
    >
    >> Howdy,
    >>
    >> I'm trying to time how long it takes dd to run on a G5, versus how
    >> long it takes to run on a G4 (PATA vs. SATA). Both sytems have Mac OS
    >> X 10.3.2 and Python 2.3. Could someone demonstrate how I might use
    >> Python to monitor for the presense of a process and to do something
    >> (in this case send an email which I know how to do) as soon as that
    >> process is no longer present? Any suggestions on how to monitor? Call
    >> top every 5 secs and read it's output searching for 'dd'???
    >>
    >> TIA,
    >> Bart
    >>

    >
    > I forgot to mention the fact that I already know when the process began.
    > All I need to know is when it ends and then I can calculate the part in
    > between those two points.
    >


    Why not just:

    import time
    import os
    start = time.time()
    s = os.system('dd <args>')
    print time.time()-start


    - Josiah
     
    Josiah Carlson, Jan 23, 2004
    #3
  4. Bart Nessux

    Bart Nessux Guest

    Josiah Carlson wrote:
    > Bart Nessux wrote:
    >
    >> Bart Nessux wrote:
    >>
    >>> Howdy,
    >>>
    >>> I'm trying to time how long it takes dd to run on a G5, versus how
    >>> long it takes to run on a G4 (PATA vs. SATA). Both sytems have Mac OS
    >>> X 10.3.2 and Python 2.3. Could someone demonstrate how I might use
    >>> Python to monitor for the presense of a process and to do something
    >>> (in this case send an email which I know how to do) as soon as that
    >>> process is no longer present? Any suggestions on how to monitor? Call
    >>> top every 5 secs and read it's output searching for 'dd'???
    >>>
    >>> TIA,
    >>> Bart
    >>>

    >>
    >> I forgot to mention the fact that I already know when the process
    >> began. All I need to know is when it ends and then I can calculate the
    >> part in between those two points.
    >>

    >
    > Why not just:
    >
    > import time
    > import os
    > start = time.time()
    > s = os.system('dd <args>')
    > print time.time()-start
    >
    >
    > - Josiah


    That works great... i didn't think of using time (the module)... had to
    rewrite my function to contain sub-functions so that I could time each
    piece of it seperately. Thanks for the tip!!!

    Bart
     
    Bart Nessux, Jan 23, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jona
    Replies:
    2
    Views:
    806
  2. John English
    Replies:
    0
    Views:
    5,221
    John English
    Nov 7, 2005
  3. SB
    Replies:
    6
    Views:
    323
    Old Wolf
    Apr 23, 2004
  4. Elhanan
    Replies:
    17
    Views:
    658
  5. Victor Hooi
    Replies:
    1
    Views:
    135
    Nobody
    Feb 10, 2013
Loading...

Share This Page