我使用这个命令来运行我的工作。
(time bash executeScript 1 input fileOutput $> scrOutput) &> timeUse.txt
我使用数字1来运行这个工程,但每次运行都需要更改进程数,而且每次运行都需要很长时间才能完成。因此,我想将其作为后台进程运行。
我尝试过:
nohup ((time bash executeScript 1 input fileOutput $> scrOutput) &> timeUse.txt)
但它不起作用。
我使用这个命令来运行我的工作。
(time bash executeScript 1 input fileOutput $> scrOutput) &> timeUse.txt
我使用数字1来运行这个工程,但每次运行都需要更改进程数,而且每次运行都需要很长时间才能完成。因此,我想将其作为后台进程运行。
我尝试过:
nohup ((time bash executeScript 1 input fileOutput $> scrOutput) &> timeUse.txt)
但它不起作用。
通常情况下,我使用nohup CMD &
来运行一个后台进程。但是,如果命令的形式不被nohup
接受,则会通过bash -c "..."
运行它。
例如:
nohup bash -c "(time ./script arg1 arg2 > script.out) &> time_n_err.out" &
脚本的标准输出被写入script.out
,而错误输出和time
的输出被写入time_n_err.out
。
因此,在您的情况下:
nohup bash -c "(time bash executeScript 1 input fileOutput > scrOutput) &> timeUse.txt" &
你可以编写一个脚本,然后使用 nohup ./yourscript &
来执行。
例如:
vi yourscript
放置
#!/bin/bash
script here
你可能还需要更改在服务器上运行脚本的权限。
chmod u+rwx yourscript
最终
nohup ./yourscript &
Use screen: Start screen
, start your script, press Ctrl+A, D. Reattach with screen -r
.
Make a script that takes your "1" as a parameter, run nohup yourscript
:
#!/bin/bash
(time bash executeScript $1 input fileOutput $> scrOutput) &> timeUse.txt