Yes, just run the command in the background and exit the terminal emulator gracefully (use either Ctrl+D or exit
):
command &
For example, firefox &
.
In the BASH shell, the ampersand (&
) means "run this command as a backround process". If you close the terminal from which you launched it using either exit
or Ctrl+D, the program will keep running. If you close the terminal by clicking on it's windows "X" it will also kill the process.
To bring a process back to the foreground (from the same terminal or tty) run fg
. To send a process launched normally to the background, type Ctrl+Z in the terminal you launched it from.
Other ways to run processes in a way that is independent of the terminal emulator that launched them are the following (always using firefox as an example):
nohup
. From the nohup
manpage:
nohup - run a command immune to hangups, with output to a non-tty
If standard input is a terminal, redirect it from /dev/null. If standard output is a terminal,
append output to nohup.out' if possible,
$HOME/nohup.out' otherwise. If standard error is a
terminal, redirect it to standard output. To save output to FILE, use `nohup COMMAND > FILE'.
Example:
nohup firefox
at
, from the at
manpage:
at, batch, atq, atrm - queue, examine or delete jobs for later execution
at executes commands at a specified time.
The usage is slightly more complex, you need to have a text file that contains the command(s) you want to run, one per line. Then you launch at
, telling it to execute at a specific time:
echo "firefox" > command.txt
at 14:56 < command.txt
The example above tells at
to launch the commands listed in the file command.txt
at 14:56 PM.
NOTE: Using either at
or nohup
, the process launched will keep running after exiting X.