Leave neuron running and close the session

Post Reply
patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

Leave neuron running and close the session

Post by patoorio » Mon Dec 20, 2010 2:19 pm

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

ted
Site Admin
Posts: 5591
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Leave neuron running and close the session

Post by ted » Tue Dec 21, 2010 2:12 pm

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.

patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

Re: Leave neuron running and close the session

Post by patoorio » Tue Dec 21, 2010 3:20 pm

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?

ted
Site Admin
Posts: 5591
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Leave neuron running and close the session

Post by ted » Wed Dec 22, 2010 12:44 am

That's a fair question.
nrngui -help
reveals some interesting things, including this answer to your question:
nrngui -nogui

patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

Re: Leave neuron running and close the session

Post by patoorio » Wed Dec 22, 2010 8:12 am

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!

ted
Site Admin
Posts: 5591
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Leave neuron running and close the session

Post by ted » Wed Dec 22, 2010 1:12 pm

Excellent! I am sure that other NEURON users will find this to be useful. Thanks for asking the question that led to this answer.

vsekulic
Posts: 6
Joined: Sun Dec 26, 2010 7:55 pm

Re: Leave neuron running and close the session

Post by vsekulic » Sun Dec 26, 2010 8:08 pm

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.

ted
Site Admin
Posts: 5591
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Leave neuron running and close the session

Post by ted » Mon Dec 27, 2010 2:30 pm

Outstanding tip. screen is an underused gem.

patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

Re: Leave neuron running and close the session

Post by patoorio » Mon Dec 27, 2010 9:01 pm

Thanks!!
I'll give it a try.Sounds really amazing!

Post Reply