fgコマンドの説明します。

説明

fgはでコマンドやスクリプトをフォアグラウンド(同期)で実行するコマンドです。

使い方:fg
読み方:エフジー
  略:foreground

具体例

# ■■■ 1.事前準備
# 作業ディレクトリ作成
[root@CE08PRD101 ~]# mkdir -p /work/fg;cd /work/fg;pwd
/work/fg

# ディレクトリ確認
[root@CE08PRD101 fg]# ll
合計 0

# 「pingを30回打ち、結果をファイルに出力する」処理をバックグラウンド(非同期)で実行する
[root@CE08PRD101 fg]# (ping -c 30 google.com > fg_test.txt ) &
[1] 4298

# バックグラウンド処理の確認
[root@CE08PRD101 fg]# jobs
[1]+ 実行中 ( ping -c 30 google.com > fg_test.txt ) &

# ■■■ 2.フォアグラウンドでpingを再開させる
# pingの処理が終わるまで待つ
[root@CE08PRD101 fg]# fg %1
( ping -c 30 google.com > fg_test.txt )

# ■■■ 3.事後確認
# pingが30回打たれていることを確認する。(30 packets transmitted)
[root@CE08PRD101 fg]# cat fg_test.txt
(省略)
64 bytes from nrt12s15-in-x0e.1e100.net (2404:6800:4004:807::200e): icmp_seq=27 ttl=117 time=13.1 ms
64 bytes from nrt12s15-in-x0e.1e100.net (2404:6800:4004:807::200e): icmp_seq=28 ttl=117 time=13.3 ms
64 bytes from nrt12s15-in-x0e.1e100.net (2404:6800:4004:807::200e): icmp_seq=29 ttl=117 time=12.9 ms
64 bytes from nrt12s15-in-x0e.1e100.net (2404:6800:4004:807::200e): icmp_seq=30 ttl=117 time=12.9 ms
--- google.com ping statistics ---
30 packets transmitted, 30 received, 0% packet loss, time 88ms
rtt min/avg/max/mdev = 12.761/13.233/13.982/0.260 ms

# 作業ディレクトリ削除
[root@CE08PRD101 fg]# cd ../;rm -fr fg