如何在没有标准输入的情况下启动结构任务

时间:2014-02-24 07:22:06

标签: fabric

我需要使用另一个shell脚本启动一堆任务。

我想使用nohup模式运行shell脚本,但是由于没有stdin,结构会拒绝继续

Traceback (most recent call last):
      File "/home/user/local/lib/python2.7/site-packages/Fabric-1.8.0-py2.7.egg/fabric/main.py", line 743, in main
        *args, **kwargs
      File "/home/user/local/lib/python2.7/site-packages/Fabric-1.8.0-py2.7.egg/fabric/tasks.py", line 368, in execute
        multiprocessing
      File "/home/user/local/lib/python2.7/site-packages/Fabric-1.8.0-py2.7.egg/fabric/tasks.py", line 264, in _execute
        return task.run(*args, **kwargs)
      File "/home/user/local/lib/python2.7/site-packages/Fabric-1.8.0-py2.7.egg/fabric/tasks.py", line 171, in run
        return self.wrapped(*args, **kwargs)
      File "/home/ubuntu/utils/deploy_to_ubuntu/deploy_worker.py", line 84, in deploy_existing
        run('sudo sh ~/existing_setup.sh')
      File "/home/user/local/lib/python2.7/site-packages/Fabric-1.8.0-py2.7.egg/fabric/network.py", line 578, in host_prompting_wrapper
        return func(*args, **kwargs)
      File "/home/user/local/lib/python2.7/site-packages/Fabric-1.8.0-py2.7.egg/fabric/operations.py", line 1042, in run
        shell_escape=shell_escape)
      File "/home/user/local/lib/python2.7/site-packages/Fabric-1.8.0-py2.7.egg/fabric/operations.py", line 911, in _run_command
        stderr=stderr, timeout=timeout)
      File "/home/user/local/lib/python2.7/site-packages/Fabric-1.8.0-py2.7.egg/fabric/operations.py", line 795, in _execute
        worker.raise_if_needed()
      File "/home/user/local/lib/python2.7/site-packages/Fabric-1.8.0-py2.7.egg/fabric/thread_handling.py", line 12, in wrapper
        callable(*args, **kwargs)
      File "/home/user/local/lib/python2.7/site-packages/Fabric-1.8.0-py2.7.egg/fabric/io.py", line 215, in input_loop
        byte = msvcrt.getch() if win32 else sys.stdin.read(1)
    IOError: [Errno 9] Bad file descriptor

我不需要stdin出现在任何终端上。

我使用--no-pty选项在shellcript中运行fabric,但它根本没有帮助

根本不可能不运行此nohup模式,因为它需要大约10个小时我不希望终端打开这么久。

shellscript看起来像这样:

fab --no-pty deploy.add_new_server
python runtests.py
python add_another_server_to_config.py
fab --no-pty deploy.add_new_server
python runtests.py
.
.
.

我运行nohup deploy_and_test.sh &

1 个答案:

答案 0 :(得分:3)

很简单。

 nohup deploy_and_test.sh </dev/null &