
我是 Ubuntu 新手。我用過 Sublime Text。我意識到,從終端機打開 Sublime Text 後,如果關閉終端,應用程式將繼續運作。對於其他應用程式(例如geany
.
從終端打開應用程式後,當我關閉終端時,應用程式也會關閉。我已經嘗試過&exit
了geany &exit
。但這不是我要找的。
geany
關閉後如何繼續運作?
答案1
編輯:這可能僅適用於某些類型的終端。最好disown
在啟動以下命令後再執行一個命令,以便應用程式與終端機視窗解除關聯。
從終端機視窗中輸入
nohup geany > /dev/null
disown
或者
nohup geany >/dev/null &
disown
nohup
允許應用程式運行並且不受掛起影響,因此關閉終端機視窗不會對正在運行的應用程式產生影響。將 新增至命令中可以防止在執行應用程式的每個目錄中>/dev/null
建立。nohup.out
從手冊頁:
NAME
nohup - run a command immune to hangups, with output to a non-tty
SYNOPSIS
nohup COMMAND [ARG]...
nohup OPTION
和
$ disown --help
disown: disown [-h] [-ar] [jobspec ... | pid ...]
Remove jobs from current shell.
Removes each JOBSPEC argument from the table of active jobs. Without
any JOBSPECs, the shell uses its notion of the current job.
Options:
-a remove all jobs if JOBSPEC is not supplied
-h mark each JOBSPEC so that SIGHUP is not sent to the job if the
shell receives a SIGHUP
-r remove only running jobs
Exit Status:
Returns success unless an invalid option or JOBSPEC is given.
答案2
作為替代方案,nohup
您可以使用內建的 shell disown
。disown
從作業清單中刪除作業,並且當 shell 存在時,SIGHUP
不會將作業傳送到該進程。
geany &
disown
exit
答案3
exec geany & exit
如果您不需要 root 並且pkexec geany & exit
需要 root 權限,則可以使用(注意 exec 和&符號)。