如何在Linux中使用nohup将进程作为后台进程运行? [英] How can I use nohup to run process as a background process in linux?

查看:159
本文介绍了如何在Linux中使用nohup将进程作为后台进程运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此命令来运行我的工作.

I use this command to run my work.

(time bash executeScript 1 input fileOutput $> scrOutput) &> timeUse.txt

同时,我使用了1个进程来运行此工作.我必须更改每次运行的进程数.每次都要花费很长时间才能完成.然后我想将其作为后台进程运行.

While, 1 is a number of process that I use to run this work. I have to change the number of process for each run. At each time it use long time to complete. Then I want to run it as background process.

我该怎么办?

我尝试过:

nohup ((time bash executeScript 1 input fileOutput $> scrOutput) &> timeUse.txt)

但这是行不通的.

推荐答案

通常,我使用nohup CMD &运行nohup后台进程.但是,当命令采用nohup不会接受的形式时,我将通过bash -c "..."运行它.

In general, I use nohup CMD & to run a nohup background process. However, when the command is in a form that nohup won't accept then I run it through bash -c "...".

例如:

nohup bash -c "(time ./script arg1 arg2 > script.out) &> time_n_err.out" &

脚本中的

stdout被写入script.out,而stderr和time的输出进入time_n_err.out.

stdout from the script gets written to script.out, while stderr and the output of time goes into time_n_err.out.

因此,在您的情况下:

nohup bash -c "(time bash executeScript 1 input fileOutput > scrOutput) &> timeUse.txt" &

这篇关于如何在Linux中使用nohup将进程作为后台进程运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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