Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 7 down vote accepted

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.
share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
    
-1 as this won't work for the requirement to keep running after terminal is closed. +1 for suggesting screen/tmux. –  gertvdijk Dec 5 '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 5 '12 at 12:54
    
I was using Konsole and running Kate in it with & appended. Kate will close subsequently after closing Konsole. –  gertvdijk Dec 5 '12 at 13:01

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

exit
share|improve this answer
    
A comment on the downvote might be helpful. –  user unknown Aug 20 '12 at 0:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.