Proc::PidFile::Info - gather proces info from PID files


version 0.02


  use Proc::PidFile::Info;

  my $info = Proc::PidFile::Info->new(
    locations => [
    info_level => 1,

  foreach my $pidfile ( $info->pidfiles() ) {
    print "Service $pidfile->{name} running with PID $pidfile->{pid}, started on " . scalar( localtime ( $pidfile->{ctime} ) ) . "\n";


This module scans a list of PID file locations and/or directories containing PID files (such as /var/run) and gathers information from the PID files it finds. The PID files must have a .pid extension.

The name of the file (with the .pid extension stripped) is assumed to be the name of the service or daemon that created the PID file. The creation time of the PID file is assumed to be the timestamp when the service or daemon was last (re)started. The module can also read the PID from the PID file. The information gathered is returned as an array of hashes. Each hash describes the information for a PID file and it's associated service or daemon.



Stores the locations in which the scanner searches for PID files. PID files must have a .pid extension.

Default value: /var/run


Specifies how much information the scanner will gather from the PID files

level 0

Scans only file name and creation time. The info hashes will contain only the name and ctime keys.

level 1

Also opens each PID file and reads the PID from it. The info hashes will also contain the pid key, in addition to level 0 keys.

Default value: 0


A boolean flag which causes the scanner to automatically initiate a scan after object construction.

Default value: 1



Creates a new PID file scanner objects. Arguments are:


A list of files and directories to scan. See locations


How much detail to extract from PID files. See info_level


If true, the scanner will perform a scan right after it is constructed. See autoscan


Scans all the locations and gathers PID file information. This method is automatically called on object initialization, if the autoscan property is set to true.


Returns the information gathered from the PID files. If the autoscan property is set to false, you must call the "scan" method to gather the information first. Depending upon the calling context a list ot an array reference is returned.


Christian-Rolf Gruen <>


This software is copyright (c) 2012 by Christian-Rolf Gruen.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.