How to capture a process Id and also add a trigger when that process finishes in a bash script?
问题 I am trying to make a bash script to start a jar file and do it in the background. For that reason I'm using nohup . Right now I can capture the pid of the java process but I also need to be able to execute a command when the process finishes. This is how I started nohup java -jar jarfile.jar & echo $! > conf/pid I also know from this answer that using ; will make a command execute after the first one finishes. nohup java -jar jarfile.jar; echo "done" echo "done" is just an example. My