ssh can use to run remote commands.

ssh [email protected] 'long-script.sh'

I run a long script that will take a lot of time, but I want to close my computer and keep running the script in the remote server. I know how to achieve this with GNU Screen, but I need do it via ssh.

Can I do that without interrupting my script?

  • 3
    What's wrong with starting screen on the remote server?
    – choroba
    Commented Jan 19, 2012 at 14:52

3 Answers 3


Use "nohup" to run a command immune to hangups, with output to a non-tty:

nohup your_command &

and to run a command via ssh, without first logging into the remote machine:

ssh user_name@machine_address "nohup your_script.sh" &
$ ssh [email protected] screen -dm long-script.sh

ssh user@server "nohup script.sh >/var/log/output.log 2>&1 &"

That should run the remote command without leaving a running ssh process on your client.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .