当前位置: 首页 > news >正文

越秀区建设水务局网站东莞市做网站公司

越秀区建设水务局网站,东莞市做网站公司,家装网站建设公司,学编程的好处trap 命令用于指定在接收到信号后将要采取的动作#xff0c;常见的用途是在脚本程序被中断时完成清理工作。当 shell 接收到 sigspec 指定的信号时#xff0c; arg 参数(通常是执行命令)会被读取#xff0c;并被执行。 1. 命令介绍 开始掌握基本的使用方式和方法 [1] 语法…trap 命令用于指定在接收到信号后将要采取的动作常见的用途是在脚本程序被中断时完成清理工作。当 shell 接收到 sigspec 指定的信号时 arg 参数(通常是执行命令)会被读取并被执行。 1. 命令介绍 开始掌握基本的使用方式和方法 [1] 语法格式 trap [-lp] [[arg] sigspec …] [2] 参数选项 编号 参数 含义 1 -p 列出当前设置的 trap 方法 2 -l 列出信号名称和相应的数字 [3] 常用的信号量 Number Name Notes 0 EXIT Always run on shell exit, regardless of exit code 1 SIGHUP - 2 SIGINT This is what ^C sends 3 SIGQUIT - 6 SIGABRT - 9 SIGKILL - 14 SIGALRM - 15 SIGTERM This is what kill sends by default 2. 实例说明 纸上得来终觉浅绝知此事要躬行。 [1] 累计在退出时运行的trap工作列表 #on_exit and add_on_exit #Usage: #add_on_exit rm -f /tmp/foo #add_on_exit echo “I am exiting” #tempfileKaTeX parse error: Expected EOF, got # at position 10: (mktemp) #̲add_on_exit rm …tempfile function on_exit() { for i in “${on_exit_items[]}”; do eval $i done } function add_on_exit() { local nKaTeX parse error: Expected }, got # at position 2: {#̲on_exit_items[*…n]“$*” if [[ $n -eq 0 ]]; then trap on_exit EXIT fi } add_on_exit echo “I am exiting” [2] 捕获SIGINT或CtrlC #Run a command on signal 2 (SIGINT, which is what ^C sends) function sigint() { echo “Killed subshell!” } trap sigint INT #This will be killed on the first ^C echo “Sleeping…” sleep 500 echo “Sleeping…” sleep 500 #pressing ^C twice in a second to quit last0 function allow_quit() { [ $(date %s) -lt $(( KaTeX parse error: Expected EOF, got at position 15: last 1 )) ] ̲ exit echo…(date %s) } trap allow_quit INT [3] 清理临时文件 #Make a cleanup function function cleanup() { rm --force – “${tmp}” } #Trap special “EXIT” group, which is always run when the shell exits. trap cleanup EXIT #Create a temporary file tmp“(mktemp−p/tmptmpfileXXXXXXX)echoHello,world!(mktemp -p /tmp tmpfileXXXXXXX) echo Hello, world! (mktemp−p/tmptmpfileXXXXXXX)echoHello,world!{tmp}” [4] 在退出时杀死子进程 #kill all spawned child processes of the shell on exit trap ‘jobs -p | xargs kill’ EXIT [5] 对终端窗口大小的变化做出反应 #signal WINCH(WINdowCHange) that is fired when one resizes a terminal window declare -x rows cols function update_size(){ rowsKaTeX parse error: Expected EOF, got # at position 14: (tput lines) #̲ get actual lin…(tput cols) # get actual columns of term echo DEBUG terminal window has no $rows lines and is $cols characters wide } trap update_size WINCH 3. 删除进程树 一条命令也可以完成一个脚本的工作量 #How to get PID,PGID,sessionid etc ? $ ps -o pid,ppid,pgid,gid,sess,cmd -U root PID PPID PGID GID SESS CMD #1.kill a group of processes with negative PID(Process ID) $ kill -TERM -PID #2. kill a group of processes with their PGID(Process Group ID) $ kill – -$PGID Kill using the default signal (TERM 15) $ kill -9 -$PGID Kill using the KILL signal (9) #3. kill a group processes with only PID info $ kill – -$(ps -o pgid $PID | grep -o [0-9]*) #4.Using pkill, kill processes by PGID(Proess Group ID) $ pkill -9 -g $PGID #5.Using pkill, kill processes by GID(Group ID) $ pkill -9 -G $GID #6.Using pkill, kill processes by PPID(Parent Process ID) $ pkill -9 -p $PPID #7.Using pkill, kill processes by terminal $ pkill -9 -t $terminal #8.Using pkill, kill processes by process name $ pkill -9 -x $process_name #9.Using pkill, kill processes by session $ pkill -9 -s $sess 新的一年 新的征程 新的课程开班 等你来学
http://www.hkea.cn/news/14546628/

相关文章:

  • win7 做网站服务器asp.net 网站开发项目
  • 甘肃两学一做网站手机版商城网站案例
  • 网站建设素材包用h5开发的网站模板下载
  • 合肥做网站工作室个人网站建立多少钱
  • 品牌网站建设小8蝌蚪如何在手机上开自己的网站
  • 郑州七彩网站建设公司怎么样虚拟主机有几种类型
  • 天天seo站长工具域名提交收录
  • 网站访问量查询工具广州做网站建设哪家专业
  • 优秀个人网站模板下载网站建设策划方
  • 微信网站建站平台做电商一般月入多少钱
  • 网站大全app下载推广公司业务发朋友圈
  • 那块做微信平台网站小程序商店有哪些
  • 网站建设安全吗台州市临海建设局网站
  • 网站推广营销方法专业提供网站建设服务是什么
  • 网站备案 座机百度销售岗位怎么样
  • 网站新闻页面设计怎么才能建立一个网站卖东西
  • 国家建设部网站查询模板网站建设方案
  • 电商网站开发流程合肥网站推广优化公司
  • 温江建网站kol推广是什么意思
  • 商丘网站建设运营公司越秀网站建设
  • 出国做网站工作手机cms建站系统
  • 成都便宜网站建设全国妇联官方网站儿童之家建设
  • 争对银行排队做一网站做生物卷子的网站
  • 天网站建设子网站如何做
  • 网站建设 中标乐山市住房和城乡规划建设局网站
  • 成都建设网官方网站wordpress 文件存储
  • 响应式网站研究现状移动应用开发适合女生吗
  • 宁波网站建设制作环境设计专业就业方向
  • 重庆做网站letidewordpress+缩略图截图
  • 网站建设有哪些技术html做企业门户网站