check procee id exists

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
时间: 2024-11-13 06:54:24

check procee id exists的相关文章

LoadRunner 报 invalid application path!please check if application exists

首次学习使用LoadRunner.说一下错误产生的环境,已经解决的方法. 开始电脑上安装的有360浏览器,但是在录制上总是不成功(显示页面没反应),估计是360浏览器的事,把360浏览器卸载后,在开始录制脚本,确报invalid application path!please check if application exists .用的是默认的IE浏览器,不知道哪里出了问题.各种试发现Program to record栏里手动去挑选IE的存在路径C:\Program Files\Interne

Check if KeyValuePair exists with LINQ's FirstOrDefault

http://stackoverflow.com/questions/793897/check-if-keyvaluepair-exists-with-linqs-firstordefault 问题: I have a dictionary of type Dictionary<Guid,int> I want to return the first instance where a condition is met using var available = m_AvailableDict.

android操作sqlite数据库及心得

写这篇文章主要是网上的对sqlite的操作太多且太杂,很多时候都不能很好的运用到自己的项目中,结构不清晰,我自己写了一篇适合刚刚接触的人看的操作方法. 近来用android时要将一些数据保存起来,一开始用的是preferences,后来要保存的东西多了,发现用preferences明显不能满足要求了,而且发现用这个的话代码就变得有点乱了,所以才开始学习使用sqlite数据库,一开始以为不就是个数据库么,和平时的mysql啊或者是sqlserver都一样,都很简单的,但后来真正在用的时候才发现困难

Understanding Item Import and Debugging Problems with Item Import (Doc ID 268968.1)

In this Document Purpose Details   Scenario 1: Testing the basic item import with minimum columns populated   Scenario 2: To import items and use item templates   Scenario 3: To import items and material cost associated to it.   Scenario 4: To import

If Value Exists Then Query Else Allow Create New in Oracle Forms An Example

An example given below for Oracle Forms, when a value exists then execute query for that value to display the correspondent record else allow user to create a new record for that value. The following is the example given for HR schema employee table,

小表驱动大表, 兼论exists和in

给出两个表,A和B,A和B表的数据量, 当A小于B时,用exists select * from A where exists (select * from B where A.id=B.id) exists的实现,相当于外表循环,每次循环对内表进行查询? for i in A for j in B if j.id == i.id then .... 相反,如果A大于B的时候,则用in select * from A where id in (select id from B) 这种在逻辑上类似

《Distributed Programming With Ruby》读书笔记二 Security and ID Conversion (Part1.1-2)

Security Although DRb provide some security, they fall short of a full, comprehensive solution. This can make DRb less than desirable in a lot of real world situations. However, in situations where security is a lesser concern,such as prototyping and

Oracle中in和exists区别

1.select * from A where id in(select id from B);in适合B表比A表数据小的情况 2.select a.* from A a where exists(select 1 from B b where a.id=b.id);exists适合B表比A表数据大的情况  

MySQL优化(5):索引失效分析、in与exists使用场合

一.索引失效的情况 前文提及过可以通过explain的possible_keys.key属性判断索引是否失效,key如果为null,可能是索引没建,也可能是索引失效,下面列举一些会使索引失效的情况. 1.全值匹配:顺序.个数与索引一致 2.最佳左前缀法则:查询从索引的最左前列开始并且不跳过索引中的列,中间跳过的值,后面的索引会失效 3.索引列上做了操作(计算.函数.自动或手动类型转换),会导致索引失效而转向全表扫描 4.存储引擎不能使用索引中范围条件右边的列 name字段用于查找,age>11也