|
|
check if process is running?
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
okay, on a redhat mail server.. put spamassassin and spamass-milter on it...
I want to check if the spamd daemon is running, make sure the daemon startup script is working.
So, how do I check?
top is not useful, it can't display all 80 + processes on the server
so, perhaps with netstat or something?
|
|
|
|
|
|
|
|
|
Moderator
Join Date: May 2001
Location: Hilbert space
Status:
Offline
|
|
ps -au | grep spamd should do the trick. Or
top | grep spamd
Some daemons put their pid (process id) in /var/run (the files are unambigously called inetd.pid, etc.). You can grep the pid then or even kill [pid] (or more elegantly kill `cat cron.pid` to kill crond).
|
I don't suffer from insanity, I enjoy every minute of it.
|
|
|
|
|
|
|
|
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status:
Offline
|
|
Originally posted by OreoCookie:
ps -au | grep spamd should do the trick. Or
top | grep spamd
Some daemons put their pid (process id) in /var/run (the files are unambigously called inetd.pid, etc.). You can grep the pid then or even kill [pid] (or more elegantly kill `cat cron.pid` to kill crond).
I think you mean:
top -b -n 1 | grep spamd
The command as you wrote it would just sit there otherwise. The "top -b -n 1" is good for piping to other commands or to a file.
If he installed spamassassin via the RPM packages (the usual method for Red Hat)... then to start the service:
service spamassassin start
to stop it:
service spamassassin stop
to check its status:
service spamassassin status
The status switch will also return the the PID of the process, something like:
service spamassassin status
spamd (pid 426) is running...
If you want to see whether it is set to run on boot up do:
chkconfig --list spamassassin
spamassassin 0:off 1:off 2:on 3:on 4:on 5:on 6:off
from this you can see that it is set to start automagically in runlevels 2, 3, 4, and 5 (which is probably what you want).
There are many ways to check on and configure running services... perhaps more ways than there are flavors of Unix/Linux. Red Hat and several other Red Hat based distributions have a pretty simple set of tools for this. Some are commandline some are GUI. The command line tools, some of which are demonstrated above, work quite well. They are simple enough to be easy to remember. To see a list of all possible services controlled by this feature do:
chkconfig --list
|
-DU-...etc...
|
|
|
|
|
|
|
|
Moderator
Join Date: May 2001
Location: Hilbert space
Status:
Offline
|
|
Originally posted by utidjian:
I think you mean:
top -b -n 1 | grep spamd
The command as you wrote it would just sit there otherwise. The "top -b -n 1" is good for piping to other commands or to a file.
If he installed spamassassin via the RPM packages (the usual method for Red Hat)... then to start the service:
service spamassassin start
to stop it:
service spamassassin stop
to check its status:
service spamassassin status
The status switch will also return the the PID of the process, something like:
service spamassassin status
spamd (pid 426) is running...
If you want to see whether it is set to run on boot up do:
chkconfig --list spamassassin
spamassassin 0:off 1:off 2:on 3:on 4:on 5:on 6:off
from this you can see that it is set to start automagically in runlevels 2, 3, 4, and 5 (which is probably what you want).
There are many ways to check on and configure running services... perhaps more ways than there are flavors of Unix/Linux. Red Hat and several other Red Hat based distributions have a pretty simple set of tools for this. Some are commandline some are GUI. The command line tools, some of which are demonstrated above, work quite well. They are simple enough to be easy to remember. To see a list of all possible services controlled by this feature do:
chkconfig --list
Doesn't matter to me, it's faster to about it manually than typing all the extra letters
But my guess is that spamd has a pid file in /var/run (readable by root).
|
I don't suffer from insanity, I enjoy every minute of it.
|
|
|
|
|
|
|
|
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status:
Offline
|
|
Originally posted by OreoCookie:
Doesn't matter to me, it's faster to about it manually than typing all the extra letters
But my guess is that spamd has a pid file in /var/run (readable by root).
True... but that doesn't tell you if the process is running or not. It may have started and died for some reason. The:
service servicename status
command will tell you the PID AND if it is running OR it will tell you "servicename dead but pid exists" OR it will tell you "servicename dead but subsys locked" OR "servicename stopped"... all of which is MUCH more useful for debugging.
It is also more elegant and "cleaner" to use the service command for starting and stopping a given service than to use kill. This applies especially to services like MySQL. The service scripts have been designed to handle most every service and to handle them well... one can even "restart" networking services remotely... and stay connected. (One can NOT, however, stop and then start them remotely.)
Another handy command is to run in an additional terminal window:
tail -f /var/log/messages
(or whatever in /var/log/) to see what the system is up to as a service activates.
|
-DU-...etc...
|
|
|
|
|
|
|
|
Moderator
Join Date: May 2001
Location: Hilbert space
Status:
Offline
|
|
Originally posted by utidjian:
True... but that doesn't tell you if the process is running or not. It may have started and died for some reason. The:
service servicename status
command will tell you the PID AND if it is running OR it will tell you "servicename dead but pid exists" OR it will tell you "servicename dead but subsys locked" OR "servicename stopped"... all of which is MUCH more useful for debugging.
It is also more elegant and "cleaner" to use the service command for starting and stopping a given service than to use kill. This applies especially to services like MySQL. The service scripts have been designed to handle most every service and to handle them well... one can even "restart" networking services remotely... and stay connected. (One can NOT, however, stop and then start them remotely.)
Another handy command is to run in an additional terminal window:
tail -f /var/log/messages
(or whatever in /var/log/) to see what the system is up to as a service activates.
Ok, learned something. I didn't know that the command service existed.
On my FreeBSD box, I usually have scripts that do that job directly for dhcpd or bind9.
|
I don't suffer from insanity, I enjoy every minute of it.
|
|
|
|
|
|
|
|
Junior Member
Join Date: Jan 2003
Status:
Offline
|
|
Use pgrep!
pgrep spamd
if it prints out anything then you know it's running. I wish fink had ports of pgrep/pkill, they're really useful commands.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|