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就是各进程 ...
随机推荐
- TOP100summit【分享实录-网易】构建云直播分发网络
本篇文章内容来自2016年TOP100summit网易视频云.网易杭州研究院服务端技术专家邵峰的案例分享.编辑:Cynthia 邵峰:网易视频云.网易杭州研究院服务端技术专家浙江大学计算机专业博士毕业 ...
- F#周报2018年第50期
新闻 Bolero: 用于WebAssembly的F#工具 Ionide-fsharp安装数量超过10万 WPF的Xaml.Behaviors类库开源 Visual Studio 2019预览版 .N ...
- .NET Core开发日志——Entity Framework与PostgreSQL
Entity Framework在.NET Core中被命名为Entity Framework Core.虽然一般会用于对SQL Server数据库进行数据操作,但其实它还支持其它数据库,这里就以Po ...
- WPF 依赖属性和附加属性
依赖属性: 依赖属性就是自己没有值,通过Binding从数据源获得值,就是依赖在别人身上,拥有依赖属性的对象称为依赖对象. 依赖属性的值存在哪里? 在WPF运行时,维护了一个全局的Hashtable存 ...
- Mean reversion (finance) 均值回归
Mean reversion (finance) 均值回归
- mysql缓冲
- [development][libconfig] 配置文件库
以前,一直用ini的配置文件. 简单清晰但是不灵活. 换一个: 试试libconfig 主页: http://www.hyperrealm.com/oss_libconfig.shtml githu ...
- [daily] docker
what docker is? https://www.docker.com/what-docker 一: archlinux 安装docker: 我之前装了一个, 然后好久没用, 今天发现不能用了, ...
- $ORACLE_HOME/OPatch/opatch lsinventory查oracle补丁
> $ORACLE_HOME/OPatch/opatch lsinventoryInvoking OPatch 10.2.0.4.2 Oracle Interim Patch Installer ...
- PHP 小知识
-- 获取/设置响应的 HTTP 状态码 mixed http_response_code ([ int $response_code ] ) -- ... 操作符知道是什么么?看看 PHP 官方的 ...