Pidof finds the process id’s (pids) of the named programs. It prints those id’s on the standard output.
In rpm-based linux distros, executing this combined with a daemonized service would give you a result in numeric form, which is the process id of the named program.
Usefulness?
This could be handy trying to find a specific PID ID of a multihomed full blown production server currently serving a lot of daemonized service besides from doing the grep linux command.
Another way is integrating and calling it from shell script that regularly checks a particular daemon service on regular cron basis say every 5 minutes making sure the service is alive.
I heard stories of daemon service being killed and died due to brute force attack.
One reason is, you might have a newly recruit junior sysad that accidentally for whatever reason killed and tampered that PIDs and suddenly got confused on how to fire it up again. This entry can be an extra linux reminder for that.
And lastly, this keeps you away from midnight phone calls and from standing up late at night just to start a servoce from a newly configured production server for yet an unknown cause. One of my buddies serving almost 2,000 servers had crash issues with a daemons and currently still and *unresolved ticket number from their commercial distro provider.
Here, a basic example of integrating it from a bash script which then checks for dovecot service.
check_dovecot.sh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! /bin/bash
PATH=/usr/bin:/bin
export PATH
date=`date "+%A %m-%d-%Y %r"`
# script to check dovecot
num=1
ayos=`/sbin/pidof dovecot`
if [ $dovecotid > 0 ]; then
exit 0
fi
if [ $num = 1 ]; then
echo Dead...Starting Dovecot...
/sbin/service dovecot restart
echo "Restarted at $date" | mail -s "MyServer Dovecot RESTARTED" youralertemail@yourdomain.com
else
echo Dovecot is alive!
fi
exit 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combined with cronjob as
5,10,15,20,25,30,35,40,45,50,55 * * * * YOURPATH/check_dovecot >/dev/null 2>&1
or
/5 * * * * YOURPATH/check_dovecot >/dev/null 2>&1
which does the same cron job of executing the script every 5 minutes.
FYI, expanding more of this script in parallel with another clone server would create you a this known heartbeat opensource program that deals basically with waking up backup service/servers.
hope this helps.
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
July
(107)
- AMSN messenger install howto
- firefox browser - yum update howto
- kopete messenger install howto
- Gaim pidgin messenger install howto
- xmms - multimedia player install howto
- UltraDMA - speedup your harddisk howto
- sabayon - user profile manager howto
- 50 quick linux command tips part 3
- No negotiations with Microsoft in progress
- connect SamSung D820 mobile to linux howto
- yum from ISO image or CD install howto
- missing portmap reinstall howto
- 50 quick linux command tips part 2
- 50 quick linux command tips part 1
- desktop wiki install howto
- NASA tests Linux for spacecraft control
- warzone 2100 strategy 3d game install howto
- motd - message of the day
- more with kernel name version howto
- stop and start networking service howto
- change network proxy preference howto
- alexa firefox toolbar plugin install howto
- reboot / halt system via CLI howto
- gparted partitioning install howto
- google picasa install howto
- pine and pico install howto
- adobe/macromedia flash player test and install howto
- realplayer install howto
- Microsoft's TrueType core fonts install howto
- Why Choose Fedora? (Fedora vs. Ubuntu)
- Microsoft vs Opensource
- the df command
- linux possessed by monsterz
- change display setting howto
- NTP clock synchronization howto
- qtparted partitioning magic install howto
- host name and host aliases explained
- IP aliasing - virtual IP howto
- viruskiller on linux
- change keyboard language setting
- changing ethernet card settings howto
- TIP: WiFi with chillispot and linux
- play tennis the linux way
- sudoku game install howto
- my linux box talked to me
- CD/DVD burning software install howto
- A SYSAD BLOG - LINUX: list out active host connect...
- list out active host connection howto
- more with linux command named history
- GnuPG and enigmail thunderbird add-ons
- PDF file readers install howto
- digikam - KDE photo management install howto
- gnome floppy formatter
- f-spot Gnome photo manager install howto
- VLC media player install howto
- ping IP subnet block howto
- TIP: find and delete files recursively
- list out opened host ports howto
- TIP: linux process priority scheduling management
- TIP: spammer sending email using squid
- remount partition as read only howto
- additional swap file howto
- CrossOver install howto
- system-config-securitylevel-tui and lokkit howto
- format a windows partition from linux hadrdisk
- TIP: monitoring while mounting USB devices
- zero-sized a file without permission / ownership c...
- TIP: auto create mail spool when adding user
- md5sum checksum howto
- IP address to country lookup howto
- gnome mail notification install howto
- add new harddisk to existing linux system
- TIP: block an IP address
- disk space report
- more trace route command alternatives
- changing your hardware / software clock howto
- other interesting ping commands
- send email via CLI howto
- adding static route howto
- send message to all logged in users
- unzip zip untar tar bzip2 bunzip2 gzip gunzip file...
- format of /etc/passwd, /etc/shadow and /etc/group
- remove user's cron jobs howto
- find the user's files howto
- passphraseless + passwordless ssh howto
- passwordless ssh howto
- X11 Forwarding via ssh howto
- skype install howto
- disable IPv6
- lsusb - list all USB devices
- make yum faster
- lspci - list all PCI devices
- kill a process
- beginners CLI guide for static ip address
- the pidof command
- retrieve data from mysql using bash script
- VirtualBox install howto
- call bash script inside php web page
- alternative linux browsers
- last / currently logged in users
-
▼
July
(107)
Thursday, July 5, 2007
the pidof command
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment