0

What I want to do is connect to my server and have Drush (a Drupal command-line program) run a command to start a large data import. To do this I need to SSH into the server first. So I would execute the Drush call. Then I want to be able to shut down my computer and walk away.

Will this continue to run if I do this? Someone has suggested to me that I can just put an ampersand at the end of the command and it will put the command in the background. Will that work?

The reason I ask instead of just test is because this will be a large amount of data and I don't want to start it before I am entirely ready to put it on the server.

Thoughts?

Patrick
  • 3,302
  • 4
  • 28
  • 47

2 Answers2

5

You should also take a look at screen.

What you need to know now about screen is that it emulates a terminal that may be detached and retached.

To detach press Ctrl+A,D (Control plus A, release both, then D).

And run the command screen -x to attach again.

http://www.gnu.org/s/screen/

More usefull commands:

screen -list        shows all active screens
screen -r NUMBER    retach to the screen corresponding to NUMBER
André Puel
  • 8,741
  • 9
  • 52
  • 83
  • And that would work on a Linux server that I SSH into and have no control of the installed packages??? If so then how would it be able to keep track of which process that I am reattaching after I log out and then back in? – Patrick Aug 08 '11 at 22:11
  • It is very probable that screen is already installed. Most sysadmins I know would consider it madness to set up any server _without_ having screen available. – hmakholm left over Monica Aug 08 '11 at 22:18
  • So it turns out that my server admin just sent me an article that details how to use screen for this. Ok then, screen it is. – Patrick Aug 08 '11 at 23:03
3

use

nohup yourcommand &

to do this

Erich Kitzmueller
  • 36,381
  • 5
  • 80
  • 102
  • That looks really familiar. A long long time ago I setup a PHP script to just launch a command line command and continue without waiting for it to finish and I think that this is exactly what I used. Thanks man! – Patrick Aug 08 '11 at 22:09