bgコマンドの説明します。
説明
bgはファイルを指定した行数で分割するコマンドです。
使い方:bg
読み方:ビージー
略:back ground
具体例
# ■■■ 1.事前準備
# 作業ディレクトリ作成
[root@CE08PRD101 ~]# mkdir -p /work/bg;cd /work/bg;pwd
/work/bg
# ディレクトリ確認
[root@CE08PRD101 bg]# ll
合計 0
# 最初にstart_日付ファイル、30秒後にend_日付ファイルを作成するスクリプトを作成する
[root@CE08PRD101 bg]# cat << EOS > test.sh
#!/bin/bash
echo start > start_\$(date "+%Y%m%d_%H%M%S").txt
sleep 30
wait
echo end > end_\$(date "+%Y%m%d_%H%M%S").txt
EOS
# スクリプトを実行
# すぐに、Ctrl + zを押し、スクリプトを中断させる
# [数字]の数字を確認
[root@CE08PRD101 bg]# bash test.sh
[Ctrl + z]
^Z
[1]+ 停止 bash test.sh
# ディレクトリ確認
# start_日付ファイルがあることを確認する
[root@CE08PRD101 bg]# ll
合計 8
-rw-r--r-- 1 root root 6 9月 26 11:24 start_20200926_112435.txt
-rw-r--r-- 1 root root 116 9月 26 11:24 test.sh
# バックグラウンド処理を確認
[root@CE08PRD101 bg]# jobs
[1]+ 停止 bash test.sh
# ■■■ 2.バックグラウンドで30秒待ち処理を再開する
[root@CE08PRD101 bg]# bg %1
[1]+ bash test.sh &
# ■■■ 3.事後確認
# 約30秒後にファイル確認
[root@CE08PRD101 bg]# ll
合計 12
-rw-r--r-- 1 root root 4 9月 26 11:25 end_20200926_112506.sh
-rw-r--r-- 1 root root 6 9月 26 11:24 start_20200926_112435.sh
-rw-r--r-- 1 root root 116 9月 26 11:24 test.sh
[1]+ 終了 bash test.sh
# 作業ディレクトリ削除
[root@CE08PRD101 bg]# cd ../;rm -fr bg