Could someone remind me how do I run application through the terminal, which allow me to close the terminal after the program is open. I totally forgot how to do this. Please let me know.
Asked
Active
Viewed 1.5k times
5
2 Answers
6
(command &) && exit
Example:
(firefox &) && exit

Radu Rădeanu
- 169,590
-
1
-
@Braiam Which terminal are you using?!? The terminal is already closed when firefox is opened. :) – Radu Rădeanu Mar 05 '14 at 18:31
-
1@RaduRădeanu the OP mentioned that he want to close the terminal manually – kamil Mar 05 '14 at 18:40
-
-
-
@Braiam No matter what I use, the behavior is the same: the new program is opening, when the terminal is closing. – Radu Rădeanu Mar 05 '14 at 18:43
-
1
-
-
@RaduRădeanu Ok I asked the OP and let him decide if he means manually or automatically – kamil Mar 05 '14 at 18:48
-
command &
run the command as background program and close the terminal or anything you wish. – alhelal Apr 10 '17 at 06:01
2
I think this is the best way:
nohup (command) &> /dev/null &
example:
nohup firefox &> /dev/null &
Edit: the "&> /dev/null &" redirects the output of nohup such that you do not have logs (nohup.out) See https://unix.stackexchange.com/questions/23010/how-to-make-nohup-not-create-any-output-files-and-so-not-eat-all-space
Then I can close terminal without a warning message either by the exit
command or by clicking the x on the terminal window
-
1Added information to prevent "nohup.out" log files. An alternate to nohup is disown or running your applications in screen, depending on what you want to do. screen tends to work well with ssh. – Panther Mar 05 '14 at 18:35
-
the OP said: "allow me to close the terminal" not "close terminal automatically" – kamil Mar 05 '14 at 18:45
-
-
-
-
@Olli yes, please roll back again.
&>
means redirect both standard error and standard output, it is shorthand for2>&1 >
,>&
means redirect to a file called&
which, since&
is a special character for bash, will give an error for most commands and works only by chance on thenohup
. That is not a good reason to keep a syntax error in an answer. Comparels >& /dev/null
andls &> /dev/null
. – terdon Mar 05 '14 at 19:19 -
@Olli also, while this is most certainly a syntax error, it does seem to "work" in the specific case of nohup when running in any of bash,zsh, tcsh or csh but fails in dash, ` ksh and fish. More details in my question on [unix.se]. – terdon Mar 05 '14 at 20:08
nohup
doesn't? – Braiam Mar 05 '14 at 18:41nohup
doesn't close the terminal ;) – Radu Rădeanu Mar 05 '14 at 20:08