I presume the shell being a bash.
As example I use clipit.
Code: Select all
clipit & 2>&1 >/dev/null
But when the shell is exited, clipit also gets killed. Especially when you run other programs like so, say, Porteus not recognizes your linux swap file you created on a linux journalling filesystem partition, you do not want the swapon to be killed, just because the X terminal got killed, so swapon /mnt/sdx99/mycoolyeahlinuxswapfile will fail the moment the shell you executed that command exits.
Of course for swapon to work you have to first create a swap file, we presume that was already done:
Code: Select all
# file /mnt/sdx99/mycoolyeahlinuxswapfile
/mnt/sdx99/mycoolyeahlinuxswapfile: Linux/i386 swap file (new style), version 1 (4K pages), size WHATEVER pages, LABEL=LINUXSWAP, UUID=sOme-Random-UUID
Code: Select all
swapon /mnt/sdx99/mycoolyeahlinuxswapfile & 2>&1 >/dev/null
Now the trick to detach a program from its shell: ( and ) do the trick. But it depends on your shell, this syntax is not supported by every shell. Bash does support this syntax.
I again use clipit as example, first I exited every instance via "killall clipit"
Here is what happens, as seen in "jobs" showing background jobs of the current shell when just started clipit in the background, but not detached:
Code: Select all
guest@porteus:~$ clipit & 2>&1 >/dev/null
[1] 8780
guest@porteus:~$ jobs
[1]+ Running clipit &
guest@porteus:~$ killall clipit
guest@porteus:~$
[1]+ Terminated clipit
guest@porteus:~$ jobs
guest@porteus:~$
Code: Select all
guest@porteus:~$ (clipit & 2>&1 >/dev/null)
guest@porteus:~$ jobs
guest@porteus:~$

For silencing the output of a started program, some prefer using
Code: Select all
PROGRAM < /dev/null &>/dev/null &
Code: Select all
PROGRAM & 2>&1 >/dev/null