简体   繁体   中英

unable to capture command process id

I am trying to capture the process id of the flume command with in a linux script.

the script is being executed in nohup mode : nohup 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. 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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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