On 12/20/18 2:36 PM, Patrick Dupre wrote:
Hello,
I would like to run a process on a remote machine (login through ssh and then su) which will remian running even when I close the connection.
I am not sure that a standard background process (using &) is not going to kill the process when I logout.
Make sure you have the screen RPM installed on the remote machine, then you can run the command in a screen session:
remote-machine> screen -d -m -S SomeIdentifier <command> <args>
Or from ssh on your local machine:
ssh user@remote-host "screen -d -m -S SomeIdentifier <command> <args>"
In the screen command, the "-d -m" means "run the command in a detached session". The "-S SomeIdentifier" just gives the session an identifiable name. For example, if I use
-S TestScreen
I'd get something like:
remote-machine> screen -ls There is a screen on: 7391.TestScreen (Detached) (other stuff)
Otherwise you'd get something like:
7434.pts-11.prophead (Detached) (other stuff)
To attach to the detached session, use "screen -r <sessionID>", in the example case:
remote-machine> screen -r 7391.TestScreen
Once you're attached to it, you can either "CTRL-C" to end the session or simply detach again by hitting "CTRL-A" followed by the "D" key. See "man screen" for details.
Note that if you put a space in the session identifier, you MUST enclose it in quotes so the shell doesn't try to interpret it. ---------------------------------------------------------------------- - Rick Stevens, Systems Engineer, AllDigital ricks@alldigital.com - - AIM/Skype: therps2 ICQ: 226437340 Yahoo: origrps2 - - - - Microsoft Windows: Proof that P.T. Barnum was right - ----------------------------------------------------------------------