services

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

    services

    I have a python script (file start with #!/usr/bin/python) that use
    xmlrpclib to lessen and respond on port:8000. The problem is when I
    close the shell (bash in remote with putty) the script stop to work. I
    try to start it in backgroud with & but it dosent work. Finally I copy
    and I try to modify the /etc/init.d/crond to start the script in
    services (with start-stop-demon but I have the same problem... When I
    close putty the script stop.

    Someone have a idea?

    thank's

    Laurent
  • Peter Hansen

    #2
    Re: services

    Laurent Vincelette wrote:
    [color=blue]
    > I have a python script (file start with #!/usr/bin/python) that use
    > xmlrpclib to lessen and respond on port:8000. The problem is when I
    > close the shell (bash in remote with putty) the script stop to work. I
    > try to start it in backgroud with & but it dosent work. Finally I copy
    > and I try to modify the /etc/init.d/crond to start the script in
    > services (with start-stop-demon but I have the same problem... When I
    > close putty the script stop.
    >
    > Someone have a idea?[/color]

    Redirect stdout and stderr to /dev/null. I'm not sure which of these --
    perhaps both -- is necessary, but doing both certainly works...

    That is, this should work:

    yourscript.py >/dev/null 2>/dev/null &

    -Peter

    Comment

    • John Hazen

      #3
      Re: services

      * Laurent Vincelette <lvincelette@vi deotron.ca> [2004-03-18 19:53]:[color=blue]
      > I have a python script (file start with #!/usr/bin/python) that use
      > xmlrpclib to lessen and respond on port:8000. The problem is when I
      > close the shell (bash in remote with putty) the script stop to work. I
      > try to start it in backgroud with & but it dosent work. Finally I copy
      > and I try to modify the /etc/init.d/crond to start the script in
      > services (with start-stop-demon but I have the same problem... When I
      > close putty the script stop.
      >
      > Someone have a idea?[/color]

      try:

      % nohup file.py &

      It redirects the output (and stderr) to ./nohup.out, and prevents the
      HUP signal from being sent to the process when you log out.

      And if you want the service to run at startup, I'd probably create a
      separate startup script (if it's running as a permament service, I don't
      think cron has anything to do with it) which launches it and redirects
      the output.

      -John

      <my first name> at hazen.net

      Comment

      • Peter Hansen

        #4
        Re: services

        John Hazen wrote:
        [color=blue]
        > try:
        >
        > % nohup file.py &
        >
        > It redirects the output (and stderr) to ./nohup.out, and prevents the
        > HUP signal from being sent to the process when you log out.[/color]

        Interesting!

        Note, from "info nohup", that it reduces the process' priority (i.e.
        increases the priority value by 5), and can in some cases not actually
        run the command at all.

        Still, another interesting tidbit for the toolbox.

        -Peter

        Comment

        Working...