本文共 765 字,大约阅读时间需要 2 分钟。
sh test.sh bash test.sh
/server/scripts/test.sh ./test.sh
source test.sh . test.sh第三种执行方法和前两种的区别:
nohup
nohup sh test.sh > out.txt &
out.txt为输出日志的地方
sh
sh test.sh >& out.txt &
功能 | 用途 |
---|---|
sh 脚本 & | 将要执行的脚本放到后台执行 |
ctrl + c | 停止执行当前脚本任务 |
ctrl + z | 暂停执行当前脚本任务 |
bg | 将当前脚本任务放到后台执行 |
fg | 将当前脚本任务 |
jobs
查单当前后台正在运行的任务[root@localhost scripts]# jobs[1]- Running sh jobs.sh &[2]+ Running sh jobs.sh &
fg 序列号
调出当前正在后台运行的任务到前台执行[root@localhost scripts]# fg 1sh jobs.sh
nohub
后台运行程序转载地址:http://fgvd.baihongyu.com/