Thursday, May 2, 2024
15
rated 0 times [  15] [ 0]  / answers: 1 / hits: 3636  / 3 Years ago, mon, may 17, 2021, 11:21:19

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?


More From » command-line

 Answers
7

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



bg %1 ; wait %1 ; shutdown -h now


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.


[#40676] Wednesday, May 19, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
heathree

Total Points: 157
Total Questions: 132
Total Answers: 108

Location: Honduras
Member since Mon, Apr 5, 2021
3 Years ago
;