How to Catch Ctrl-C in Shell Script
#!/bin/sh # this function is called when Ctrl-C is sent
function trap_ctrlc ()
{
# perform cleanup here
echo "Ctrl-C caught...performing clean up" echo "Doing cleanup" # exit shell script with error code
# if omitted, shell script will continue execution
exit
} # initialise trap to call trap_ctrlc function
# when signal (SIGINT) is received
trap "trap_ctrlc" # your script goes here
echo "going to sleep"
sleep
echo "end of sleep"
How to Catch Ctrl-C in Shell Script的更多相关文章
- bash shell学习-shell script基础 (笔记)
A chain no stronger than its weakest link. "一着不慎,满盘皆输" 参考资料:鸟哥的Linux私房菜 基础学习篇(第三版) Linux ...
- Shell Script Basics
https://developer.apple.com/library/mac/documentation/OpenSource/Conceptual/ShellScripting/shell_scr ...
- shell 编程 && bash 简介(shell 变量、shell操作环境、数据流重导向、管线命令、shell script)
如何学习一门编程语言 数据类型 运算符 关键字 1 认识BASH 这个shell linux是操作系统核心,用户通过shell与核心进行沟通,达到我们想要的目的.硬件.核心.用户之间的关系: 原理:所 ...
- shell及脚本4——shell script
一.格式 1.1 开头 必须以 "# !/bin/bash" 开头,告诉系统这是一个bash shell脚本.注意#与!中间有空格. 二.语法 2.1 数值运算 可以用decla ...
- shell script
一.shell script的编写与执行 1.shell script 的编写中还需要用到下面的注意事项: a.命令的执行是从上到下,从左到右地分析与执行 b.命令.参数间的多个空白都会被忽略掉 c. ...
- (copy) Shell Script to Check Linux System Health
source: http://linoxide.com/linux-shell-script/shell-script-check-linux-system-health/ This article ...
- shell script练习
执行脚本的几种方式: 1. sh a.sh 或者 bash a.sh 调用的是 /bin/bash 进程执行的,所以脚本不需要执行权限. 2. 直接使用绝对路径执行, /home/script/a ...
- 这些年我们一起搞过的持续集成~Jenkins+Perl and Shell script
这些年我们一起搞过的持续集成~Jenkins+Perl and Shell script ##转载注明出处:http://www.cnblogs.com/wade-xu/p/4378224.html ...
- CentOS Linux下一个tomcat起停,查看日志的shell script
CentOS 的tomcat安装目录:/usr/local/tomcat vi MyTomcatUitl.sh 创建文件chmod u+x MyTomcatUtil.sh 赋执行 ...
随机推荐
- HDU.3032.Nim or not Nim?(博弈论 Lasker's Nim)
题目链接 \(Description\) 有多堆石子, 每次可以将任意一堆拿走任意个或者将这一堆分成非空的两堆, 拿走最后一颗石子的人胜利.问谁会获得胜利. \(Solution\) Lasker's ...
- SolidWorks知识积累系列-01
Solidworks学习 1. 基本知识点总结 基准视图 主视图:从前往后看,前视基准 俯视图:从上往下看,上视基准 侧视图:从右向左看,右视基准 草图要求 单封闭性,草图要依附于某个位置 绘制大概形 ...
- Python3练习题系列(08)——代码阅读方法及字典跳转表理解
问题:分析下面代码 cities['_find'] = find_city city_found = cities['_find'](cities, state) 分析过程: 一个函数也可以作为一个变 ...
- zabbix 添加被监控主机
点击 configured > host > create host 主机名:输入主机名,允许使用字母数字,空格,点,破折号和下划线 组:从右侧选择框中选择一个或多个组,然后单击 « 将其 ...
- php null
null 表示一个变量没有值,并且不区分大小写 在下列情况下一个变量被认为是 NULL: 1.被赋值为 NULL. 2.尚未被赋值. 3.被 unset(). 判断是否为null : is_null ...
- SSH使用自定义私钥进行登录
ssh -i /root/.ssh/id_rsa root@192.168.1.2 -i指定了私钥文件的路径
- boost.xml_parser中文字符问题 (转)
当使用xml_parser进行读xml时,如果遇到中文字符会出现解析错误. 网上有解决方案说使用wptree来实现,但当使用wptree来写xml时也会出错.而使用ptree来写中文时不会出错. 综合 ...
- packageOfficialDebug和resourceFile does not exist.
Android Studio运行时候报packageOfficialDebug错误 报错信息为 Error:A problem was found with the configuration of ...
- 从源码编译InfluxDB
操作系统 : CentOS7.3.1611_x64 go语言版本:1.8.3 linux/amd64 InfluxDB版本:1.1.0 go语言安装参考: http://www.cnblogs.com ...
- mysql如何处理亿级数据,第一个阶段——优化SQL语句
1.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索引而进行全表扫描. 2.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉 ...