How to suspend a script?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    How to suspend a script?

    Hi,

    How can I send a python script a suspend signal? I need to suspend a
    script that frequently updates the database so that I can do a "vacuum"
    on the database without affecting the script. Thanks!

    Steve

  • Steve

    #2
    Re: How to suspend a script?

    Steve wrote:[color=blue]
    > Hi,
    >
    > How can I send a python script a suspend signal? I need to suspend a
    > script that frequently updates the database so that I can do a "vacuum"
    > on the database without affecting the script. Thanks!
    >
    > Steve
    >[/color]


    I would like to add that I want it to be a cron job so I need to do
    something externally. This might be a trivial thing to do but I'm a
    newbie and I'm not too fluent with linux.

    Steve

    Comment

    • Ben Finney

      #3
      Re: How to suspend a script?

      On Wed, 25 Feb 2004 11:29:07 +1100, Steve wrote:[color=blue]
      > How can I send a python script a suspend signal?[/color]

      You can send any signal to a process with the (poorly-named) 'kill'
      command. You'll need to do so as a user with permission to control that
      process. See the 'kill(1)' manpage for more.

      --
      \ "Say what you will about the Ten Commandments, you must always |
      `\ come back to the pleasant fact that there are only ten of |
      _o__) them." -- Henry L. Mencken |
      Ben Finney <http://bignose.squidly .org/>

      Comment

      • Greg Ewing (using news.cis.dfn.de)

        #4
        Re: How to suspend a script?

        Ben Finney wrote:[color=blue]
        > On Wed, 25 Feb 2004 11:29:07 +1100, Steve wrote:
        >[color=green]
        >>How can I send a python script a suspend signal?[/color]
        >
        > You can send any signal to a process with the (poorly-named) 'kill'
        > command.[/color]

        Also it doesn't matter whether it's a Python program
        or anything else -- the OS intercepts the SIGSTOP
        or SIGTSTP signals and suspends the process until
        it receives a SIGCONT signal.

        Note that this will indiscriminatel y suspend the
        process in the middle of whatever it happened to
        be doing at the time. This could have bad effects
        if e.g. the process is updating the database and
        has part of it locked.

        If that's a problem, you may need to use some other
        signal and arrange for the Python code to catch
        the signal and suspend itself when it's safe to
        do so. It can do that using the pause() function
        in the signal module.

        --
        Greg Ewing, Computer Science Dept,
        University of Canterbury,
        Christchurch, New Zealand


        Comment

        • Frithiof Andreas Jensen

          #5
          Re: How to suspend a script?


          "Steve" <nospam@nopes > wrote in message
          news:403bed20$1 @clarion.carno. net.au...[color=blue]
          >
          > I would like to add that I want it to be a cron job so I need to do
          > something externally. This might be a trivial thing to do but I'm a
          > newbie and I'm not too fluent with linux.[/color]

          You should try it in Windows then ;-)


          Comment

          Working...