![実行中のプロセスにSIGHUPを無視するように指示するにはどうすればよいですか? [コピー]](https://linux33.com/image/19983/%E5%AE%9F%E8%A1%8C%E4%B8%AD%E3%81%AE%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E3%81%ABSIGHUP%E3%82%92%E7%84%A1%E8%A6%96%E3%81%99%E3%82%8B%E3%82%88%E3%81%86%E3%81%AB%E6%8C%87%E7%A4%BA%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%99%E3%81%8B%EF%BC%9F%20%5B%E3%82%B3%E3%83%94%E3%83%BC%5D.png)
私は時々SSH経由でアクセスするDebian Squeezeを実行する低コストの「サーバー」を持っています。システムが遅い傾向があります。たとえば、apt-cache search
実行には30分かかります。時にはプロセスが完了するのを待つことができないことがわかります(ノートブックを使用しているので、別の場所に行く必要があります)。
nohup
screen
最初に。しかし、ログアウトしてもすでに実行中のプロセスを実行し続けるにはどうすればよいですか?
答え1
bash、ksh、zsh、または他の同様のシェルを使用していると仮定すると、プロセスをバックグラウンドに置いて実行できますdisown
。具体bash
的には、次のものが必要な場合がありますdisown -h
。
Bashヘルプページからdisown
:
disown: disown [-h] [-ar] [jobspec ...]
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
disown
Bashまたはzshを使用している場合は、ログアウトする前に組み込みコマンドを使用してください。
からman zshall
:
disown [ job ... ]
job ... &|
job ... &!
Remove the specified jobs from the job table; the shell will no
longer report their status, and will not complain if you try to
exit an interactive shell with them running or stopped. If no
job is specified, disown the current job.