Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > check if process is running?

check if process is running?
Thread Tools
11011001
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
May 24, 2003, 04:24 AM
 
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?
     
OreoCookie
Moderator
Join Date: May 2001
Location: Hilbert space
Status: Offline
Reply With Quote
May 24, 2003, 05:28 AM
 
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.
     
utidjian
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
May 24, 2003, 11:20 AM
 
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...
     
OreoCookie
Moderator
Join Date: May 2001
Location: Hilbert space
Status: Offline
Reply With Quote
May 24, 2003, 04:38 PM
 
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.
     
utidjian
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
May 24, 2003, 07:16 PM
 
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...
     
OreoCookie
Moderator
Join Date: May 2001
Location: Hilbert space
Status: Offline
Reply With Quote
May 25, 2003, 04:51 AM
 
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.
     
Tritium
Junior Member
Join Date: Jan 2003
Status: Offline
Reply With Quote
May 25, 2003, 09:31 AM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 12:43 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,