[Rear-users] Use pidof instead of locking

Gratien D'haese gratien.dhaese at it3.be
Mon Apr 4 11:27:32 CEST 2011


On Mon, 04 Apr 2011 10:45:57 +0200, Schlomo Schapiro
<schlomo at schapiro.org>
wrote:

Output from Fedora:

# ./pidoftest.sh
Starting instance of ./pidoftest.sh (sleeping 10sec)
pidof is '/sbin/pidof' and comes from
'sysvinit-tools-2.88-2.dsf.fc15.i686'
LSB Version:    :core-4.0-ia32:core-4.0-noarch
Distributor ID: Fedora
Description:    Fedora release 15 (Rawhide)
Release:        15
Codename:       Rawhide

# usr/share/rear/contrib/pidoftest.sh
Starting instance of usr/share/rear/contrib/pidoftest.sh (sleeping 10sec)
pidof is '/sbin/pidof' and comes from
'sysvinit-tools-2.87-7.dsf.fc14.i686'
LSB Version:    :core-4.0-ia32:core-4.0-noarch
Distributor ID: Fedora
Description:    Fedora release 14 (Laughlin)
Release:        14
Codename:       Laughlin

PS: last friday I did bash pidoftest.sh which found bash of course more
then once ;-/

> Hi,
> 
> I checked in my test script under contrib/ to make sure that we all test
> the same, output looks like this:
> 
> $ contrib/pidoftest.sh
> Starting instance of contrib/pidoftest.sh (sleeping 10sec)
> pidof is '/bin/pidof' and comes from 'sysvinit-utils'
> Distributor ID:	Ubuntu
> Description:	Ubuntu 10.10
> Release:	10.10
> Codename:	maverick
> 
> # ./pidoftest.sh
> Starting instance of ./pidoftest.sh (sleeping 10sec)
> pidof is '/sbin/pidof' and comes from 'SysVinit-2.86-15.el5'
> LSB Version:
>
:core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
> Distributor ID: CentOS
> Description:    CentOS release 5.5 (Final)
> Release:        5.5
> Codename:       Final
> 
> Maybe on Fedora 15 you also need to install sysvinit-utils or somethink
> like this? I guess that lots of other software is also relying on these
> tools so that I would be very much surprised if Fedora 15 is lacking
> them. In any case we pull already all kind of software in (lsb_release,
> ldd, syslinux, mkisofs ...) so that it won't hurt to pull in the
> sysvinit-utils as well.
> 
> Kind Regards,
> Schlomo
> 
> PS: My motivation in this is to replace a lockdir and lockfile and a
> more-than-screen full of code with 3 lines using pidof and still be at
> least equally safe as with the lockdir.
> 
> Am 01.04.2011 19:43, schrieb Gratien D'haese:
>> Hi,
>> 
>> on CentOS pidof is not standard available. On Fedora it doesn't work
>> either as I always get "" as result of a pidof.
>> That was one of the main reasons why I choose for a simplistic locking
>> mechanism as it works everywhere...
>> 
>> Gratien
>> 
>> On 01 Apr 2011, at 15:03, Schlomo Schapiro wrote:
>> 
>>> ME="$(type -p "$0" || readlink -f "$0")"
>>>
>>> # do not run if another instance is running. pidof -x will always
report
>>> at least $$
>>> if [ $$ != "$(pidof -x "$ME")" ] ; then
>>>        echo "$ME is already running"
>>>        exit 0
>>> fi
>> 
>> 
>>
------------------------------------------------------------------------------
>> Create and publish websites with WebMatrix
>> Use the most popular FREE web apps or write code yourself; 
>> WebMatrix provides all the features you need to develop and 
>> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
>> _______________________________________________
>> Rear-users mailing list
>> Rear-users at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rear-users
> 
>
------------------------------------------------------------------------------
> Create and publish websites with WebMatrix
> Use the most popular FREE web apps or write code yourself; 
> WebMatrix provides all the features you need to develop and 
> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
> _______________________________________________
> Rear-users mailing list
> Rear-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rear-users

-- 
Gratien D'haese
IT3 Consultants bvba 
Fredericusstraat 48, B-2640 Mortsel




More information about the rear-users mailing list