[英]terminal linux (Centos6) : how to exec command -> get PID in output + log file + without waiting?
I tried to run a command in the terminal that should have these features:我试图在终端中运行一个应该具有以下功能的命令:
1) get in output only the PID without wait execution 1) 只输出PID,不等待执行
2) save log stdout , stderr in a file 2) 将日志 stdout , stderr 保存在一个文件中
i tried with this :我试过这个:
echo $! | php test.php | tee log.txt &2>&1 /dev/null
but it returns me in output on the terminal both the stdout and stderr.但它在终端的输出中返回我的标准输出和标准错误。 then unfortunately we have to wait for the execution -.-
然后不幸的是我们必须等待执行-.-
can someone help me on how to build the command?有人可以帮助我如何构建命令吗?
you can use您可以使用
(echo $! | php test.php | tee log.txt &2>&1 /dev/null) &
alternatively或者
nohup (echo $! | php test.php | tee log.txt &2>&1 /dev/null) &
nohup
runs a command immune to hangups, with output to a non-tty nohup
运行一个不受挂断影响的命令,输出到非 tty
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.