I am running jobs on a remote server using torque. I currently have a an annoying problem.

When I run my jobs this is what I currently do:

  1. Log into another computer via Teamviewer
  2. From that computer ssh into the remote server as so ssh [email protected]
  3. Here i run my job script sh verycomplicatedrunscript.sh which echos to the user something like:

    I am now running job 1...

    I am now running job 2...

    I am now running job 3...

    I am now running job 4...

just to show that it is running and what it is running.

Only problem is that this takes several days as the jobs are somewhat large and there are thousands of them.

Now, I would like to bypass the Teamviewer step and just ssh into the remote from my own computer. But if I do that, and run my jobs script, and then close the terminal; it kills the process (hence why I am currently running it on the other computer which I can just leave running for days by leaving the terminal open).

Is there any way in which I can execute the script on the remote server, and then logout without it killing the execution of my jobs script?



I ended up using the screen option which is quite frankly amazing.

My jobs are now running with

screen sh awesomejobscript.sh option1 option2 option3

  • 1
    Run it under screen then detach and close ssh.
    – Fallen
    Commented Jan 15, 2016 at 10:01
  • This wiki.harvard.edu/confluence/display/USERDOCS/… ?
    – Astrid
    Commented Jan 15, 2016 at 10:02
  • 1
    Yep, but this is more user-friendly, if you want the lazy man way, you'd run like this: screen ./script.sh then CTRL+A+D to detach, and when you want to get back at it, screen -r or if running multiple screen sessions, save the PID (or the start of it on your head) and screen -r PID
    – Fallen
    Commented Jan 15, 2016 at 10:04
  • BTW, I don't think this belongs to stackoverflow, this sounds more of unix.stackexchange or superuser.
    – Fallen
    Commented Jan 15, 2016 at 10:07
  • Ok thanks, I'll take a look at it and I've flagged the question for migration.
    – Astrid
    Commented Jan 15, 2016 at 10:16

2 Answers 2


Just use nohup:

$ ssh [email protected] "nohup complexscript.sh > mylog 2>&1 &" 

There are many solutions it turns out, in addition to the one above;

screen sh jobscript.sh op1 op2 op3

works very well too.

You must log in to answer this question.

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