On a regular basis I forget to add && shutdown -h now to a long-running process. Is there any way to add a shutdown -h now command after the first command was invoked? It is not intended to interrupt the ongoing process. Maybe it is possible to watch the PID?
|
|
||||
|
There's no need to repeatedly run ps to list all processes and grep through the output. Background the process with ctrl-Z, then run
If you have other background jobs running, then you will be given a different jobspec instead of [1] when you ctrl-z. If so, use that instead. |
|||
|
|
|
You could do something like this, which will check whether the process is running every 5 seconds and take appropriate action:
Note the square brackets in the |
|||||||||
|
|
If You know the pid you can run this:
To run without echo from ps do this:
And finally to run it in the background without any output:
Scott's solution is a good one but this removes the need to |
||||
|
|
|
I do this all the time.
Alternatively, you can poll as suggested in other answers like this:
|
|||
|
Make a shell script to run both processes: MyShellScript.txt:
After saving this in the directory where you start the given process, do a:
Then when you want to run the command just type |
||||
|
|

&&will only run if the previous command was successful. If you want it to run even if the command fails use;instead. – Zoke Jan 30 '12 at 2:49