首页 > 系统服务 > 详细

shell 中的作业管理命令 fg bg   jobs nohup

时间:2017-01-10 22:38:39      阅读:303      评论:0      收藏:0      [点我收藏+]


cat a.sh


#!/bin/bash


for i in `seq 100 `


do


  echo "the script is running"

  sleep 2


done


执行脚本


[root@localhost ~]# ./a.sh 

the script is running

the script is running

the script is running


使用ctrl+z 暂停命令 


使用 jobs 可以在当前shell 中看到命令


技术分享


使用 fg % 1 可以让任务在前台运行


技术分享

使用 bg % 1 可以让任务在后台运行,使用ctrl+c 终止命令 ,命令也会运行,关闭当前shell 终端即可


技术分享


使用nohup 命令运行命令,关闭当前shell 也不影响任务运行


nohup ./a.sh & 




本文出自 “sdsca” 博客,请务必保留此出处http://sdsca.blog.51cto.com/10852974/1890839

shell 中的作业管理命令 fg bg   jobs nohup

原文:http://sdsca.blog.51cto.com/10852974/1890839

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!