Page 1 of 1

Leave neuron running and close the session

Posted: Mon Dec 20, 2010 2:19 pm
by patoorio
Hi,

I've set up a Linux machine to be used exclusively for running simulations. The idea is to run neuron both locally and remotely, depending on the kind of simulation. In the remote case (and maybe in the local case too), I would like to start a simulation and be able to close the session (to shutdown the 'client' computer, for instance) without interrupting the simulation.
How can that be done?

Regards

Re: Leave neuron running and close the session

Posted: Tue Dec 21, 2010 2:12 pm
by ted
If a program requires no user interaction*, you can run it in the background in a subshell, e.g.
% (programname -options &)
Then it should continue to execute after you log out. For more information you may want to read about "job control" and "disowning processes" in a reference on UNIX or Linux.

*--if the program generates terminal output or expects terminal input, you may be able to use redirection to satisfy these i/o requirements.

Re: Leave neuron running and close the session

Posted: Tue Dec 21, 2010 3:20 pm
by patoorio
Thanks,
Then I guess neuron will have to be started without the GUI, right? but nrniv doesn't read additional mechanisms present in the directory as nrngui does, so what would be the correct way of starting the process?

Re: Leave neuron running and close the session

Posted: Wed Dec 22, 2010 12:44 am
by ted
That's a fair question.
nrngui -help
reveals some interesting things, including this answer to your question:
nrngui -nogui

Re: Leave neuron running and close the session

Posted: Wed Dec 22, 2010 8:12 am
by patoorio
Thanks a lot!
I don't know why the subshell trick does not work for me, but if I do
nrngui -nogui myfile.hoc &

and then
disown processID

it's just what I need. The simulation keeps running after logout!

Re: Leave neuron running and close the session

Posted: Wed Dec 22, 2010 1:12 pm
by ted
Excellent! I am sure that other NEURON users will find this to be useful. Thanks for asking the question that led to this answer.

Re: Leave neuron running and close the session

Posted: Sun Dec 26, 2010 8:08 pm
by vsekulic
You can also run NEURON within a "screen" session. GNU screen is a standard Linux/Unix program that can manage multiple shell sessions for you (i.e., "screens") and keep them running even if you're not logged into the system. Think of it as a "window manager" for the terminal. You can read the manual page by running "man screen" while logged into your Linux system. There are a lot of options and it's an extremely versatile program, but there are plenty of online tutorials if you search for them in Google.

For basic usage, this is how I use screen:

Code: Select all

$ ssh myhost
myhost$ screen
--new screen session started--
myhost$ nrngui -nogui myfile.hoc
myhost$ <CTRL-A> <d>
--screen session detached--
myhost$ exit
$

(Some time later)

$ ssh myhost
$ screen -R -D
--screen session resumed--
(nrngui still running from before in terminal)
One advantage here is that you don't have to redirect output to a file (though you may still want to do so if your program will output a lot of data and you want to look at it afterwards) as you would if you're putting it into the background using the "&" method.

There's a bit of a learning curve to screen, but I've found it invaluable whenever I'm running programs on a remote system. It can even be simply used as "basic insurance" in case your connection is broken. If you're running everything within screen, your programs continue running, and you just have to login again and resume the session with no loss of productivity.

Re: Leave neuron running and close the session

Posted: Mon Dec 27, 2010 2:30 pm
by ted
Outstanding tip. screen is an underused gem.

Re: Leave neuron running and close the session

Posted: Mon Dec 27, 2010 9:01 pm
by patoorio
Thanks!!
I'll give it a try.Sounds really amazing!