简体   繁体   English

无法捕获命令进程ID

[英]unable to capture command process id

I am trying to capture the process id of the flume command with in a linux script. 我正在尝试在Linux脚本中捕获flume命令的进程ID。

the script is being executed in nohup mode : nohup flume.sh & 脚本以nohup模式执行: nohup flume.sh&

flume.sh: flume.sh:

flume-ng agent --conf . -Dflume.root.logger=info,console -Djavax.net.debug=info,console --conf-file FLUME_Surya.conf --name IBMMQ  --classpath $CLASSPATH -Dcom.ibm.mq.cfg.useIBMCipherMappings=false
echo $! > /biph/edl/SG/jobs/Src-104000-IPS_SG/CUL_FLUME_PROCESS_ID.txt

after the script is execute the text file is still empty, please advice 执行脚本后,文本文件仍然为空,请咨询

$! contains the process id of the most recent background job. 包含最新后台作业的进程ID。 That is, job placed in the background by putting a & at the end of the line. 也就是说,通过在行的末尾添加&来将作业置于后台。 In your script nothing is put into the background, and thus $! 在脚本中,什么都没有放在后台,因此$! is empty. 是空的。 (The echo command line will open the file, creating it if it doesn't exist and truncate it if it does. But it has nothing to write to it.) echo命令行将打开该文件,如果该文件不存在则创建该文件,如果存在则截断该文件。但是没有任何内容可写。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM