linux - How to keep remote script running when dropping ssh?
2013-08
I ssh
from my MacBook to a remote Linux and started a lengthy script (import 2000000+ lines of csv text records into MySQL). Too bad I have to take away my MacBook one hour later.
How can I keep the script running when I unplug my MacBook?
Use nohup and run your process in the background. Run your process like this:
nohup command &
Edit:
To nohup running processes: press ctrl+z, enter "bg" and enter "disown"
nohup is fine, but spartian. screen is powerful. Let's do:
screen
command
type Control-A, then d. This will detach the screen session. You'll see the detached session with:
screen -ls
To reattach a session:
screen -r
See also this screen presentation
How do you run a ssh server on Mac OS X?
Go to System Preferences -> Sharing, enable Remote Login.
In System Preferences under Sharing is an option for "Remote Login".
This will run sshd at startup (through the launch-daemon) and enable SSH access with standard options. To tweak the sshd options, edit /etc/sshd_config (you'll need to do this in a sudo shell or via "sudo vi /etc/sshd_config").