如何将织物与dtach,屏幕一起使用,是否有一些示例 [英] HOW TO use fabric use with dtach,screen,is there some example

查看:65
本文介绍了如何将织物与dtach,屏幕一起使用,是否有一些示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了很多东西,并且在面料常见问题中还说要与它一起使用screen dtach,但是没有找到如何实现它的方法? 下面是我的错误代码,sh不会执行,除非它是一个nohup任务

i have googled a lot,and in fabric faq also said use screen dtach with it ,but didn't find how to implement it? bellow is my wrong code,the sh will not execute as excepted it is a nohup task

def dispatch():
    run("cd /export/workspace/build/ && if [ -f spider-fetcher.zip ];then mv spider-fetcher.zip spider-fetcher.zip.bak;fi")
    put("/root/build/spider-fetcher.zip","/export/workspace/build/")
    run("cd /export/script/ && sh ./restartCrawl.sh && echo 'finished'")

推荐答案

我已经分两步做到了:

  1. 以分离模式在远程服务器上启动tmux会话:

  1. Start tmux session on remote server in detached mode:

run("tmux new -d -s foo"")

run("tmux new -d -s foo")

  • 将命令发送到分离的tmux会话:

  • Send command to the detached tmux session:

    run("tmux send -t foo.0 ls ENTER")

    run("tmux send -t foo.0 ls ENTER")

  • 此处"-t"确定目标会话("foo"),"foo.0"告诉 要在其中执行"ls"命令的窗格的编号.

    here '-t' determines target session ('foo') and 'foo.0' tells the number of the pane the 'ls' command is to be executed in.

    这篇关于如何将织物与dtach,屏幕一起使用,是否有一些示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆