zoukankan      html  css  js  c++  java
  • 作业调度(后台运行)

    kill

    用 kill 命令可以关闭进程 id

    sleep

      停顿 ,sleep 1 停顿一秒,常用于写脚本的时候

      例如 : cmd1

         sleep 1

         cmd2

         sleep 1

         cmd3

      在cmd1和cmd2之间添加停顿

    命令 CTRL +Z 把进程暂停并挂到后台

    可以用 jobs命令查看 ,bg id命令开启后台程序 ,fg id命令将后台程序放置前台

    编写如下脚本;

    用vim 编写一个脚本名叫 hello.sh ,内容是没过10秒写一个 hello

    运行脚本 sh hello.sh ,后台挂起程序,再bg执行,那么,就算脚本挂在后台执行,也会显示 hello

    [root@yxlll ~]# sh hello.sh 
    ^Z
    [1]+  Stopped                 sh hello.sh
    [root@yxlll ~]# bg 1
    [1]+ sh hello.sh &
    [root@yxlll ~]# hello
    hello

    然后,用fg 可以把脚本挂在前台显示,用 kill可以关闭脚本进程

    [root@yxlll ~]# vim hello.sh
    while true
    do
            sleep 10
            echo hello
    done
    ~                                                                                                                              
    ~                                                                                                                              
                                                                                                                                
    "hello.sh" [New] 5L, 41C written                                                                             
    [root@yxlll ~]# sh hello.sh 
    ^Z
    [1]+  Stopped                 sh hello.sh
    [root@yxlll ~]# bg 1
    [1]+ sh hello.sh &
    [root@yxlll ~]# jhello
    obs
    [1]+  Running                 sh hello.sh &
    [root@yxlll ~]# jobs
    [1]+  Running                 sh hello.sh &
    [root@yxlll ~]# fg 1
    sh hello.sh
    hello
    ^Z
    [1]+  Stopped                 sh hello.sh
    [root@yxlll ~]# jobs
    [1]+  Stopped                 sh hello.sh
    [root@yxlll ~]# kill %1
    
    [1]+  Stopped                 sh hello.sh
    [root@yxlll ~]# jobs
    [1]+  Terminated              sh hello.sh
    [root@yxlll ~]# jobs
  • 相关阅读:
    C++计时器:毫秒级和微秒级
    28款GitHub最流行的开源机器学习项目
    图像旋转公式 旋转中心点
    JNA
    this
    Random Javascript code snippets
    type
    TreeView的异步延时加载
    C#递归所以部门展示到TreeView
    C#判断是否是节假日
  • 原文地址:https://www.cnblogs.com/yxlll/p/14172180.html
Copyright © 2011-2022 走看看