Fabric cannot call remote script with nohup

In the remote server, I have a test.sh script like:

#!/bin/bash echo "I'm here!" nohup sleep 100& 

From local, I run "fab runtest" to call remote test.sh.

 def runtest(): run('xxxx/test.sh') 

I can get the output "I'm here!", But I can not find the sleep process in the remote server. What did I miss?

Thanks!

+4
source share
3 answers

Can I run nohup inside a script on a remote computer?

I checked here the answer and Frequently Asked Questions about Fabric , and also get tips from the fabric, run apache2 but not , and it works for me to combine them together

You can keep test.sh intact and add pty=False with the appropriate shell redirection.

 from fabric.api import * def runtest(): run("nohup /tmp/test.sh >& /dev/null < /dev/null &",pty=False) 

At least it works for me.

+6
source

According to Fabric Frequently Asked Questions, you can no longer do this effectively. Instead, you should use tmux, screen, dtach, or even better use the daemon python package :

 import daemon from spam import do_main_program with daemon.DaemonContext(): do_main_program() 
+3
source

We ran into this problem and found that you can use nohup in a command, but not in the script itself.

For example, run('nohup xxxx/test.sh') works.

+2
source

Source: https://habr.com/ru/post/1345673/


All Articles