You are not logged in.

#1 2008-01-27 13:13:42

Ilya
Member
From: Russia, Saint-Petersburg
Registered: 2007-08-16
Posts: 98

Apache status

How to check Apache status in command line: started or stopped?

Other Linux distributions has more options for services. For example, /etc/rc.d/httpd status. As i see Arch can only stop or start hmm

Offline

#2 2008-01-27 19:34:27

remote
Member
Registered: 2007-12-28
Posts: 44

Re: Apache status

Maybe give "netstat -ta" a go for daemon status.
If you only want to see if apache is listening, "netstat -ta |grep http" instead of the list.

Offline

#3 2008-01-27 20:01:29

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: Apache status

if [ ! -z "$(pgrep httpd)" ]; then 
  echo "apache is running"
else 
  echo "apache is not running"
fi

"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#4 2008-01-27 20:06:11

Ilya
Member
From: Russia, Saint-Petersburg
Registered: 2007-08-16
Posts: 98

Re: Apache status

Thanks, cactus smile

How Arch knows about services (from /etc/rc.d) that it must stop (for example) on shutdown?

Offline

#5 2008-01-27 20:21:00

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: Apache status

from /etc/rc.d/functions

add_daemon() {
        [ -d /var/run/daemons ] || mkdir -p /var/run/daemons
        touch /var/run/daemons/$1
}

So you could look in /var/run/daemons, but that won't help you if the process has crashed (it would have an entry but not be running).


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#6 2008-01-28 00:31:32

Ilya
Member
From: Russia, Saint-Petersburg
Registered: 2007-08-16
Posts: 98

Re: Apache status

Is there a difference between
- run Apache via '/etc/rc.d/httpd start'
- run Apache via 'apachectl start'
(except that apachectl don't create /var/run/daemons/httpd)?

Last edited by Ilya (2008-01-28 00:31:57)

Offline

#7 2008-01-28 00:47:05

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: Apache status

cat /etc/rc.d/httpd

That shows you what happens when you use the init script.


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#8 2008-01-28 09:08:07

Ilya
Member
From: Russia, Saint-Petersburg
Registered: 2007-08-16
Posts: 98

Re: Apache status

Thanks, cactus.

Also i found, that apachectl is a bash-script too smile It has command-line option status (inside, not in help), it requires lynx neutral and produce strange output...

# apachectl status
                               Object not found!

   The requested URL was not found on this server. If you entered the URL
   manually please check your spelling and try again.

   If you think this is a server error, please contact the [1]webmaster.

Error 404


    [2]localhost
    Mon Jan 28 12:01:50 2008
    Apache

Ссылки

   1. mailto:admin@server
   2. http://localhost/

So better way to check Apache status is
- to use script /etc/rc.d/httpd to start/stop
- and check presence of file /var/run/daemons/httpd for status

Last edited by Ilya (2008-01-28 09:09:26)

Offline

#9 2008-01-28 09:34:30

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Offline

#10 2008-01-28 13:33:39

Ilya
Member
From: Russia, Saint-Petersburg
Registered: 2007-08-16
Posts: 98

Re: Apache status

From Apache manual:

In order to stop or restart Apache, you must send a signal to the running httpd processes. ... You will notice many httpd executables running on your system, but you should not send signals to any of them except the parent, whose pid is in the PidFile. That is to say you shouldn't ever need to send signals to any process except the parent. ...

To send a signal to the parent you should issue a command such as:

kill -TERM `cat /usr/local/apache2/logs/httpd.pid`

/usr/local/apache2/logs/httpd.pid = /var/run/httpd.pid in Arch
just check existence of file /var/run/httpd.pid big_smile

Last edited by Ilya (2008-01-28 13:34:41)

Offline

Board footer

Powered by FluxBB