Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

ssh can use to run remote commands.

ssh me@server.com '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?

share|improve this question
What's wrong with starting screen on the remote server? – choroba Jan 19 '12 at 14:52
up vote 6 down vote accepted

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" &
share|improve this answer
$ ssh me@server.com screen -dm long-script.sh
share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.