Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5982769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:08:04+00:00 2026-05-22T22:08:04+00:00

I need to use fabfile to remotely start some program in remote boxes from

  • 0

I need to use fabfile to remotely start some program in remote boxes from time to time, and get the results. Since the program takes a long while to finish, I wish to make it run in background and so I dont need to wait. So I tried os.fork() to make it work. The problem is that when I ssh to the remote box, and run the program with os.fork() there, the program can work in background fine, but when I tried to use fabfile’s run, sudo to start the program remotely, os.fork() cannot work, the program just die silently. So I switched to Python-daemon to daemonalize the program. For a great while, it worked perfectly. But now when I started to make my program to read some Python shelve dicts, python-daemon cannot work any longer. Seems like if you use python-daemon, the shelve dicts cannot be loaded correctly, which I dont know why. Anyone has an idea besides os.fork() and Python-daemon, what else can I try to solve my problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:08:04+00:00Added an answer on May 22, 2026 at 10:08 pm

    If I understand your question right, I think you’re making this far too complicated. os.fork() is for multiprocessing, not for running a program in the background.

    Let’s say for the sake of discussion that you wanted to run program.sh and collect what it sends to standard output. To do this with fabric, create locally:

    fabfile.py:

    from fabric.api import run
    def runmyprogram():
        run('./program.sh > output 2> /dev/null < /dev/null &')
    

    Then, locally, run:

    fab -H remotebox runmyprogram
    

    The program will execute remotely, but fabric will not wait for it to finish. You’ll need to harvest the output files later, perhaps using scp. The “&” makes this run in the background on the remote machine, and output redirection is necessary to avoid a hung fabric session.

    If you don’t need to use fabric, there are easier ways of doing this. You can ssh individually and run

    nohup ./program.sh > output &
    

    then come back later to check output.

    If this is something that you’ll do on a regular basis, this might be the better option, since you can just set up a cron job to run every so often, and then collect the output whenever you want.

    If you’d rather not harvest the output files later, you can use:

    fabfile.py:

    from fabric.api import run
    def runmyprogram():
        run('./program.sh')
    

    Then, on your local machine:

    fab -H remotebox runmyprogram > output &
    

    The jobs will run remotely, and put all their output back into the local output file. This runs in the background on your local machine, so you can do other things. However, if the connection between your local and remote machines might be interrupted, it’s better to use the first approach so the output is always safely stored on the remote machines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use NSImage which appears need to be imported from <AppKit/AppKit.h> .
I need to use a many to many relationship in my project and since
I need to use sendmail from Macs in an office. At the moment, I
I need to use a datetime.strptime on the text which looks like follows. Some
I need to use lists for my program and needed to decide if I
What is the need/use of 'symbols' in the Microsoft debugger ? I spent some
I need to use some fairly complex Jquery plugins that aren't just a single
I have two tables (Master, Responses) I need use the Master_Id field from the
We are using JBoss 4.2 GA, and need use a newest version in some
I need to use sed to convert all occurences of ##XXX## to ${XXX} .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.