Running python automatically in the background

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

    Running python automatically in the background

    hi all,

    i'm trying to figure out if there is some easy way to run a python
    script in the background _without_ specifying "&" in a linux
    enivornment.

    script.py &

    vs

    script.py

    is there an easy way to do this?

    been looking around but couldn't find any docs to support a
    possibility.

    thanks!

    - al
  • Ben Finney

    #2
    Re: Running python automatically in the background

    On 27 Jan 2004 17:29:53 -0800, Alfred wrote:[color=blue]
    > i'm trying to figure out if there is some easy way to run a python
    > script in the background _without_ specifying "&" in a linux
    > enivornment.
    >
    > script.py &[/color]

    That's how you tell any POSIX-compatible shell (like bash) to execute a
    command as a background job. Why is that not acceptable?
    [color=blue]
    > been looking around but couldn't find any docs to support a
    > possibility.[/color]

    Perhaps if you explain what it is you're trying to achieve, we can offer
    a better solution.

    --
    \ "We used to laugh at Grandpa when he'd head off and go fishing. |
    `\ But we wouldn't be laughing that evening when he'd come back |
    _o__) with some whore he picked up in town." -- Jack Handey |
    Ben Finney <http://bignose.squidly .org/>

    Comment

    • Cameron Laird

      #3
      Re: Running python automatically in the background

      In article <slrnc1e4c4.14j .bignose-hates-spam@rose.local domain.fake>,
      Ben Finney <bignose-hates-spam@and-benfinney-does-too.id.au> wrote:[color=blue]
      >On 27 Jan 2004 17:29:53 -0800, Alfred wrote:[color=green]
      >> i'm trying to figure out if there is some easy way to run a python
      >> script in the background _without_ specifying "&" in a linux
      >> enivornment.
      >>
      >> script.py &[/color]
      >
      >That's how you tell any POSIX-compatible shell (like bash) to execute a
      >command as a background job. Why is that not acceptable?
      >[color=green]
      >> been looking around but couldn't find any docs to support a
      >> possibility.[/color]
      >
      >Perhaps if you explain what it is you're trying to achieve, we can offer
      >a better solution.[/color]

      Comment

      • Michael Surette

        #4
        Re: Running python automatically in the background

        On Tue, 27 Jan 2004 17:29:53 -0800, Alfred wrote:
        [color=blue]
        > hi all,
        >
        > i'm trying to figure out if there is some easy way to run a python
        > script in the background _without_ specifying "&" in a linux
        > enivornment.
        >
        > script.py &
        >
        > vs
        >
        > script.py
        >
        > is there an easy way to do this?
        >
        > been looking around but couldn't find any docs to support a
        > possibility.
        >
        > thanks!
        >
        > - al[/color]
        I forget where I first found this snippet, but it's probably what you want.

        PID= os.fork()
        if PID != 0: sys.exit()

        Comment

        Working...