You are not logged in.
Pages: 1
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
Offline
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
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
Thanks, cactus
How Arch knows about services (from /etc/rc.d) that it must stop (for example) on shutdown?
Offline
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
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
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
Thanks, cactus.
Also i found, that apachectl is a bash-script too It has command-line option status (inside, not in help), it requires lynx 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
Offline
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
Last edited by Ilya (2008-01-28 13:34:41)
Offline
Pages: 1