Tuesday, 20 May 2014
Linux: nohup and ampersand (&)
When in a linux shell (Debian, in my case), you may want to run several commands in the same shell, or even close it and keep the programs you called running.
If you want to edit a textfile, lets say, potato.txt, you'll use gedit (or any other text editor):
gedit potato.txt
However you won't be able to write in that terminal until you close gedit. If you want to use your terminal while editing potato.txt, type instead:
gedit potato.txt &
If you suddenly close your terminal, gedit will close and you're likely to lose any data you changed. The nohup command might be the solution:
nohup gedit potato.txt &
Even if you close your terminal, gedit will keep running. If a command or program is frozen, and closing the terminal won't kill it, you might just use pkill to do it:
pkill gedit
However, there are still a lot of things I can't figure out: when I try running matlab with nohup, the splash screen will appear but matlab won't open.
In that case, screen might help you. In a shell, type:
screen
It's possible that the screen page will appear (with version, license, etc), just type ENTER. It may look like nothing changed. Type:
matlab &
Just like you'd do any other time. Matlab will start. In the shell, press CTRL+A and then D (without hitting CTRL) and your shell with dettach from Matlab. Now you can close the shell and Matlab will keep running ;)
I hope this was helpful. For more information check nohup and & and running matlab in the background.
Labels:
linux
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment