【问题标题】:How to run bash script without terminate [duplicate]如何在不终止的情况下运行 bash 脚本 [重复]
【发布时间】:2016-09-18 02:19:42
【问题描述】:

当我通过我的专用服务器上的终端运行此脚本时,它可以工作。但只有在窗口打开时(终端)。当我关闭窗口时,它会关闭运行脚本。我怎样才能让它在后台永远运行?

#!/bin/bash ./robots.sh & ./update_robots.sh & ./update_auctions_end.sh & ./auto_bidders.sh

【问题讨论】:

标签: php bash terminal


【解决方案1】:

尝试将输出发送到 null,然后您的命令窗口将不会等待输出,并且会自行处理进程:

command params > /dev/null 2>/dev/null &

【讨论】:

    【解决方案2】:

    你会想要使用“nohup”命令来做这样的事情:

    nohup ./robots.sh > /dev/null 2>&1 &
    

    希望对你有所帮助。

    您可以在此处查看 nohup 的完整详细信息:http://linux.die.net/man/1/nohup

    【讨论】:

    • 喜欢这个? #!/bin/bash nohup ./robots.sh > /dev/null 2>&1 & nohup ./update_robots.sh > /dev/null 2>&1 & nohup ./update_auctions_end.sh > /dev/null 2>&1 & nohup ./auto_bidders.sh &
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-20
    • 2017-11-14
    • 1970-01-01
    • 2022-08-15
    • 2017-12-22
    • 2021-09-15
    相关资源
    最近更新 更多