Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I launch applications from the Terminal with commands like this one :

/Applications/ &

The important part is the &.

  • For Unix / Linux / Solaris :

    • I have learned at school that adding the & makes the program live on his own.
    • I strongly remember launching a command like xeyes & and having the program running safe even after I close the shell.
  • On Mac OS X (Unix inside) :

    1. I launch an app with & and I close the Terminal window : the application exits !
    2. Why does this undesirable behaviour happen on Mac OS X ?
    3. How can this be fixed ?
share|improve this question
Related question: – Eric3 Jan 11 '15 at 2:14

When you close a terminal window, it sends a SIGHUP (hangup signal) to the shell, which then sends SIGHUP to all the processes it started. This is traditional behavior for bash and many other shells, and the traditional solution to this is to use nohup.

There are ways that different Unix machines can differ, so it's possible that the specific terminal emulators you used or the specific shells you used behaved different. But it's not specific to OS X. For example, there is a question on this same issue on Ubuntu.

share|improve this answer

Using the ampersand "&", you are telling Terminal to run the process in the background of the shell itself. Thus, when you close the shell (and kill the process), the GUI ( itself) will also close.

The correct command to launch Mail from the terminal is simply:

open -a Mail; exit

Edit: I just found this over at U&L Stack Exchange: What does ampersand mean at the end of a shell script line? The answers provided are excellent and explain exactly what's going on in more detail and better than I ever could! I highly recommend reading through it.

share|improve this answer
What about passing command-line params to the app ? Like this : /Users/nicolas/Desktop/Firefox-29-fr/ -profile "/Users/nicolas/Desktop/Firefox-29-fr/Profil-Firefox-29-fr/" -no-remote & – Nicolas Barbulesco Jun 5 '14 at 21:36
@NicolasBarbulesco That is a separate question - see the man page for open and I think a question here – Mark Jun 5 '14 at 22:52
What about launching a specific application, not being in /Applications, but at a specific path ? Like this : /Users/nicolas/Desktop/Firefox-29-fr/ -profile "/Users/nicolas/Desktop/Firefox-29-fr/Profil-Firefox-29-fr/" -no-remote & – Nicolas Barbulesco Jun 6 '14 at 11:11
@NicolasBarbulesco open [full path] , or cd to the directory and open [file]. You can use ~/ for your home folder and the special character, "asterisk", as shorter notation assuming no other strings match the value, IE: ~/De*/Fire* cetera. Or just write a simple script: cat > nameofscript ..... #! /bin/sh .... open [full path] .... ^D ..... chmod +x nameofscript..... .\nameofscript .... and optional, mv nameofscript $PATH/yourpersonalbin. Irecommend reading man open. It's a simple command, and as a simple command the tradeoff is it's not that powerful. – njboot Jun 6 '14 at 12:06
Sorry, still need to use the -a argument: open -a Applications/; exit – njboot Jun 6 '14 at 14:35

The "standard" way of accomplishing what you want to accomplish (on OS X as well as on Linux, FreeBSD or other systems) is to use the command nohup:

nohup program &

This will start program, which will run in the background relative to the shell because of the & - and will ignore hangup signals due to the nohup command.

This way the program will continue running even though you close the shell. It doesn't matter if you're closing the shell because you're closing, or you're closing the shell because you are disconnecting from a ssh connection to the computer, or similar.

share|improve this answer
This creates a file nohup.out in the current folder. Even when there is nothing to write. After a few weeks, I would have files nohup.out everywhere in my Mac. :-( – Nicolas Barbulesco Jun 5 '14 at 22:39
@NicolasBarbulesco Use either nohup command>/dev/null& or command&disown. – user495470 Sep 19 '14 at 8:10

@jksoegaard has the proper commands but as you mentioned in the comment, it creates a nohup.out file. To stop the nohup.out file from being created, you need to redirect STDOUT and STDERR somewhere else. The complete command would be nohup program &>/dev/null &. This will run your program in the background, ignoring the SIGHUP, and sending all STDOUT and STDERR to /dev/null.

However, if you didn't remember to add nohup (like in your original question), you can use the disown -arh command to mark all backgrounded running jobs to ignore the SIGHUP.

share|improve this answer
Nice answer, yet still complicated. And nice profile image. :-) – Nicolas Barbulesco Jun 6 '14 at 11:18
up vote 1 down vote accepted

I have found the solution :

(/Applications/ &)

It is simple, it is pretty, and it works !

The parentheses ( ) launch the command in a sub-shell.

share|improve this answer
This worked for me as well, thanks – frbl May 8 '15 at 9:19

I have found a solution : fighting evil with evil.

I launch my app with this kind of command :

/Applications/ & exit

The shell exits at once. And the app survives, even after I close the Terminal window.

But this solution is not very handy.

share|improve this answer
You really should be opening Applications that are bundled with open. That's future proof as bundle contents change as well as canonical. – Ian C. Jun 5 '14 at 23:09
@Ian — Here I am particularly interested in opening applications who are at a specific path, not in /Applications, and not bundled with my Mac. – Nicolas Barbulesco Jun 6 '14 at 11:33
.app folders are called "bundles", and the open command can launch them whether they are in the /Applications folder or any other folder. The "bundle" term in this context does not mean "shipped with OS X". – Andrew Medico Jun 6 '14 at 16:16
open is the same as clicking the icon. It's not the same a launching the app from the command line as the OP asks. – Ted Bigham Jan 5 at 1:14

Your Answer


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.