14

I'm trying to launch a program from the Terminal in such a way that the following occurs:

  1. Closing the Terminal does not close the program
  2. The program is not outputting anything to the Terminal while opening, using, or closing
  3. The Terminal is free to be used for other things
  4. The command is short and sweet
  5. There is no output file to worry about
Evan
  • 321
  • 2
  • 8

6 Answers6

15

See man nohup:

NAME
   nohup - run a command immune to hangups, with output to a non-tty

Answer:

nohup program-name &
waltinator
  • 37,856
8

I think this would be the most complete way:

program-name </dev/null &>/dev/null &
disown %%

Disowning the backgrounded process means the shell won't track it anymore. It won't tell you when it's done. It won't prevent you from closing your shell. %% means "the most recently backgrounded job".

If you want to hide all the details, put a function like this in your .bashrc

launch_and_forget () { "$@" </dev/null &>/dev/null & disown %%; }

Then

launch_and_forget program args "args args" ...

Give a name that's meaningful for you.

glenn jackman
  • 18,218
6

You can very simply use setsid:-

NAME
       setsid - run a program in a new session

SYNOPSIS
       setsid program [arg...]

DESCRIPTION
       setsid runs a program in a new session.

Try the following command:-

setsid <command>

Example:- setsid gedit, setsid nautilus ~/Downloads/ etc.

Pandya
  • 37,289
2

Use tmux.

First launch tmux, then run whatever command you want. You can close the tmux window, or drop back by shortcut CTRL-B D. In fact, you can even later reattach by tmux attach.

1

I would recommend either tmux, as Siyuan Ren suggested, or GNU Screen. That way, you get a new terminal for your command. You can detach it and forget about it, but you can get back if you change your mind.

Serpens
  • 111
0

I picked up, and continue to use...

(nohup program-name 2>/dev/null &)