I have a service (tomcat) that needs sudo to be started. I made a simple script on the remote server in /root/bin/test.sh
#!/bin/sh sudo service tomcat start read
(The script needs to do other stuff too, just pared down for simplicity). When I run a it directly on the remote server, tomcat starts and continues running on the server after I disconnect.
When I run it remotely, the process starts, (I can see it when paused for the "read"), but once the script ends, it's gone. (while paused for the read, run this command locally)
ps -ef | grep tomcat
I've tried various combinations of nohup, screen, and & on the commands both on the local machine and in the remote machine's test.sh script, but I can't seem to get it working.
ssh -t email@example.com "/root/bin/test.sh" ssh -t firstname.lastname@example.org "nohup /root/bin/test.sh" ssh -t email@example.com "nohup /root/bin/test.sh &" ssh -t firstname.lastname@example.org "screen /root/bin/test.sh &"