質問

I am a newbie in Fabric, and want to run one command in a background, it is written in shell script, and I have to run that command via Fabric, so lets assume I have a command in shell script as:

#!/bin/bash/
java  &

Consider this is a file named myfile.sh

Now in Fabric I am using this code to run my script as:

put('myfile.sh', '/root/temp/')
sudo('sh /root/temp/myfile.sh')

Now this should start the Java process in background but when I login to the Machine and see the jobs using jobs command, nothing is outputted.

Where is the problem please shed some light.

役に立ちましたか?

解決

Use it with

run('nohup PATH_TO_JMETER/Jmetercommand & sleep 5; exit 0)

他のヒント

maybe the process exists before you return. when you type in java, normally it shows up help message and exits. Try a sleep statement or something that lingers. and if you want to run it in the background, you could also append & to the sudo call

I use run("screen -d -m sh /root/temp/myfile.sh",pty=False). This starts a new screen session in detached mode, which will continue running after the connection is lost. I use the pty=False option because I found that when connecting to several hosts, the process would not be started in all of them without this option.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top