bgコマンドの実際の用途は何ですか?

bgコマンドの実際の用途は何ですか?

出力は次のとおりです。

[USER@SERVER ~] ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.037 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.024 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.030 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.026 ms
64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.026 ms
^Z
[1]+  Stopped                 ping localhost
[USER@SERVER ~] jobs
[1]+  Stopped                 ping localhost
[USER@SERVER ~] bg %1
[1]+ ping localhost &
64 bytes from localhost (127.0.0.1): icmp_seq=6 ttl=64 time=0.034 ms
[USER@SERVER ~] 64 bytes from localhost (127.0.0.1): icmp_seq=7 ttl=64 time=0.030 ms
64 bytes from localhost (127.0.0.1): icmp_seq=8 ttl=64 time=0.032 ms

[USER@SERVER ~] ^C
[USER@SERVER ~] ^C
[USER@SERVER ~] 64 bytes from localhost (127.0.0.1): icmp_seq=9 ttl=64 time=0.031 ms
^C
[USER@SERVER ~] 64 bytes from localhost (127.0.0.1): icmp_seq=10 ttl=64 time=0.031 ms
64 bytes from localhost (127.0.0.1): icmp_seq=11 ttl=64 time=0.028 ms
ki64 bytes from localhost (127.0.0.1): icmp_seq=12 ttl=64 time=0.030 ms
ll %64 bytes from localhost (127.0.0.1): icmp_seq=13 ttl=64 time=0.031 ms
1
[1]+  Terminated              ping localhost
[USER@SERVER ~] 



1)ローカルホストにpingを送信し始めます。
2) CTRL+Z
3) bg %1
4) CTRL+Cが動作しません。
5) それを殺すには、「kill %1」と入力する必要があります。


「bg」コマンドの実際の用途は何ですか?現実の世界ではどこに使われますか?

ベストアンサー1

bg通常、グラフィカルユーザーインターフェースを使用するほとんどのプログラムと同様に、コンソール対話のないプログラムをバックグラウンドで実行するために使用します。

例:実行したかったのですが、バックグラウンドでターミナルエミュレータを実行するのをxterm &忘れました。&したがって、を使用してフォアグラウンドxtermプロセスを停止(ブロック)Ctrl-Zし、バックグラウンドで実行を続行できますbg

Ctrl-Cバックグラウンドプロセスに送信するには、fgフォアグラウンドに戻してください(またはを使用してくださいkill -2 %1)。

おすすめ記事