以前老是用fg命令做切换,一直没有学习过这个命令到底是什么意思。。。
今天终于学习了。。。
bg 后台模式重新启动一个作业
fg 前台模式重新启动一个作业
测试脚本(书里抄的)
#!/bin/bash
# test jobs control
echo "Script Process ID: $$"
count=1
while [ $count -le 10 ]
do
echo "Loop #$count"
sleep 10
count=$[ $count + 1 ]
done
echo "End of script....."
脚本输出
[root@shell signal]# ./test10.sh
Script Process ID: 4953
Loop #1
^Z
[1]+ Stopped ./test10.sh
[root@shell signal]# jobs -l
[1]+ 4953 Stopped ./test10.sh
[root@shell signal]# bg
[1]+ ./test10.sh &
Loop #2
[root@shell signal]# jobs -l
[1]+ 4953 Running ./test10.sh &
[root@shell signal]# Loop #3
[root@shell signal]# fg
./test10.sh
Loop #4
Loop #5
Loop #6
Loop #7
基本都是书上内容,写在这里只是为了加深记忆。
如有看过的朋友,请直接略过。。。