1

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 user@remoteserver.com
  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?

Thanks

SOLUTION

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

migrated from stackoverflow.com Jan 17 '16 at 19:06

This question came from our site for professional and enthusiast programmers.

  • 1
    Run it under screen then detach and close ssh. – Fallen Jan 15 '16 at 10:01
  • 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 Jan 15 '16 at 10:04
  • BTW, I don't think this belongs to stackoverflow, this sounds more of unix.stackexchange or superuser. – Fallen Jan 15 '16 at 10:07
  • Ok thanks, I'll take a look at it and I've flagged the question for migration. – Astrid Jan 15 '16 at 10:16
3

Just use nohup:

$ ssh user@remoteserver.com "nohup complexscript.sh > mylog 2>&1 &" 
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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