0

Please help in following.

I am doing ssh user@server "source script.csh" from my home server

Let us suppose script.csh contains 10 commands :

  • 1st to 3rd command runs instantaneously

  • 4th command takes 10-12 hours to complete

  • 5th to 10th command also runs instantaneously

  • Last command copies the data back to home server.

I do want to hold to the shell of remote server for 10-12 hours. Also I want commands to run in the sequentially. I will keep monitoring for the files to come back on the home server to know the completion of my script on remote server.

How can I achieve this ?

2

You can use screen in order to run something in the background so that you can close the SSH connection. I am not familiar with csh but the call would look like this:

ssh user@server "screen -S longrunscript csh -c 'source script.csh'"

The -S longrunscript gives the screen session a name so that you can easily attach to it (even if there are other screen sessions around) using screen -x longrunscript.

  • 1
    (-x implies -r (: ) – DopeGhoti Aug 30 '17 at 17:00
  • @DopeGhoti You wouldn't expect it from reading the man page but it seems you are correct. – Hauke Laging Aug 30 '17 at 17:06
  • The main difference is that -x will attach to a screen session even if it's already attached elsewhere (which allows for multiuser screen sessions). Since it's a superset of -r, I just use it whenever I'm reconnecting to a screen session. – DopeGhoti Aug 30 '17 at 17:08
  • 1
    I can't use screen. Is there any other solution ?? – Saurabh Varshney Sep 1 '17 at 5:41
  • @SaurabhVarshney nohup command & – Hauke Laging Sep 1 '17 at 5:45

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.