check process id exists
kill -0 pid
sending the signal 0 to a given PID just checks if any process with the given PID is running and you have the permission to send a signal to it.
$ man 2 kill
If sig is 0, then no signal is sent, but error checking is still performed; this can be used to check for the existence of a process ID or process group ID.
check exists, return 0
$ pgrep httpd
46775
$ kill -0 46775
$ echo $?
0
check non-exists, return 1
$ kill -0 999999899
bash: kill: (999999899) - No such process
$ echo $?
1
kill process id stored in .pid file
#!/bin/sh
pid_file=/var/run/process.pid
kill -0 $(cat $pid_file) 2>/dev/null
if [ $? -eq 0 ]; then
kill $(cat $pid_file)
fi
check process id exists的更多相关文章
- [jQuery] check if an id exists - Google 网上论坛
[jQuery] check if an id exists - Google 网上论坛 From: http://docs.jquery.com/Frequently_Asked_Questions ...
- Process ID, Process handle, Window handle
http://forums.codeguru.com/showthread.php?392273-RESOLVED-How-to-get-window-s-HWND-from-it-s-process ...
- 查看进程id, 父进程id _How do I get the parent process ID of a given child process?
How to get parent pid from a given children pid? I know I can mannully check it under /proc, I am wo ...
- Transaction (Process ID xxx) was deadlocked on lock
Transaction (Process ID 161) was deadlocked on lock | communication buffer resources with another pr ...
- 多线程处理sql server2008出现Transaction (Process ID) was deadlocked on lock resources with another process and has been chose问题
多线程处理sql server2008某个表中的数据时,在Update记录的时候出现了[Transaction (Process ID 146) was deadlocked on lock reso ...
- loadrunner录制时弹出invalid application path!please check if application exists对话框
问题:oadrunner录制时弹出invalid application path!please check if application exists对话框 原因:IE浏览器地址不对,需要手动重新选 ...
- mysql无法启动 mysqld process already exists
1.提示:A mysqld process already exists ps 命令用于查看当前正在运行的进程. grep 是搜索 例如: ps -ef | grep mysql 表示查看所有进程里 ...
- java代码中获取进程process id(转)
另一方面,线程ID=进程ID+内部线程对象ID并不成立, 参考: blog.csdn.net/heyetina/article/details/6633901 如何在java代码中获取进 ...
- 进程ID[PID(Process ID)]与端口号[(Port ID)]的联系
1.首先声明一点:PID不是端口(port id),而是Process ID进程号的意思. 2.那么,什么是进程号? 采集网友的意见就是: 进程号,是系统分配给么一个进程的唯一标识符.PID就是各进程 ...
随机推荐
- easyui tree 更改图标
easyui tree 更改图标 ,onLoadSuccess: function (node, data) { $('#tt .tree-icon').css("background&qu ...
- 对于adc dac使用细节
1. 要更具内部线路图决定引脚分配,adc和dac绑定在一个线路上,所以设计的时候最好尽量间隔三个引脚以上,如果adc必须放到一起,请使用开关控制,但是dma等可能不能正常工作. 2.dac输出内部缓 ...
- ZOJ - 2853 Evolution 线性变换变成矩阵快速幂
题意:给你N个数,1~N分别为num[i], 以及T个 (i,j,P) 对于每组(i,j,P),让你将 num[i] 减去 P*num[i] 再把 P*num[i] 加到 num[j] 上.T个 ...
- linux 记录所有用户bash操作日志
记录所有用户登录系统的任何操作日志,以便有据可查. 1.编辑 /etc/profile文件. 1 # vim /etc/profil 2. 在其后添加如下内容 1 2 3 4 5 6 7 8 ...
- HTTP缓存机制及原理
前言 Http 缓存机制作为 web 性能优化的重要手段,对于从事 Web 开发的同学们来说,应该是知识体系库中的一个基础环节,同时对于有志成为前端架构师的同学来说是必备的知识技能.但是对于很多前端同 ...
- Eisenstein's criterion
https://en.wikipedia.org/wiki/Eisenstein%27s_criterion In mathematics, Eisenstein's criterion gives ...
- PHP之后期静态绑定
PHP后期静态绑定的(late static bindings) 理解PHP延迟静态绑定 static::中的static其实是运行时所在类的别名,并不是定义类时所在的那个类名.这个东西可以实现在父类 ...
- [redhat][centos] 让不同小版本的CentOS7使用相同的内核版本
背景: CentOS7有定期的小版本发布,即官网释出的ISO,是带着小版本号的.CentOS7可以使用平滑升级,从这些小版本号中升上去. 但是并不是每一次的更新,都在释出的ISO中,这样的话,一台既有 ...
- SQL instr()函数的格式
格式一:instr( string1, string2 ) / instr(源字符串, 目标字符串) 格式二:instr( string1, string2 [, start_positio ...
- Excel--数据对比方法
1.函数对比: 适用于两列数据对比 =IF(EXACT(A2,B2)=TRUE,"相同","不同") 2.快捷键对比: 适用于少数数据对比 选中对比两列数据,快 ...