8

So I am well aware of nohup and suffixing commands with & to ensure that they go into the background.

However if I run a graphical application - sometimes using neither seems to do the job. So what can I prefix a program/command with to ensure that it keeps running after the terminal is closed?

Industrial
  • 1,688
  • 7
  • 22
  • 29

4 Answers4

9

If you want the application to keep running when you close the terminal window you should do:

nohup chromium-browser &

You need both the nohup and the &.

  • nohup means keep this process/command running after the shell closes.
  • & means put this process/command in the background so it dose not block the shell (so you can use it for something else.
Mark
  • 242
  • 1
  • 4
5

when running a program in the background via the & operator it's still attached to your session and can be controlled with fg, bg, jobs and disown.

I also had some problems with nohup but disown might be the thing you're looking for.

When you run a program in background it has a job id:

gedit &
[1] 5647

That number in brackets [] is the interesting one. To detatch it from your session run disown %n with that number. For the above example:

disown %1

Now you can safely exit the terminal and the process will not be terminated.

Axel
  • 316
  • 1
  • 5
2

For graphical applications, simply doing something like this should work (at least, it does for me)

chromium-browser&

For terminal applications, you should use something like screen or tmux.

jrg
  • 60,101
  • 54
  • 172
  • 246
  • -1 as this won't work for the requirement to keep running after terminal is closed. +1 for suggesting screen/tmux. – gertvdijk Dec 05 '12 at 11:26
  • @gertvdijk interesting, for GUI applications it works for me. Just tested using bash. I have had instances where zsh will complain if I do that and then try to exit... – jrg Dec 05 '12 at 12:54
  • I was using Konsole and running Kate in it with `&` appended. Kate will close subsequently after closing Konsole. – gertvdijk Dec 05 '12 at 13:01
-1

Close the terminal, from which you started the graphical program, with

exit
user unknown
  • 6,447
  • 3
  • 34
  • 63