Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
3  
What's wrong with starting screen on the remote server? –  choroba Jan 19 '12 at 14:52

3 Answers 3

up vote 4 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

 
discard

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.