コマンドラインでhttpdが実行されていることをどのように確認できますか?

コマンドラインでhttpdが実行されていることをどのように確認できますか?

私のサーバー用の小さなコントロールパネルを開発しています。実行中か停止しているかを確認するコマンドが必要ですhttpd

他のサービスにも同じコードを使用できます。

ベストアンサー1

ほとんどのLinuxディストリビューションでは通常、servicesコマンドを使用できます。

$ service <service> status

はい

$ service httpd status
httpd (pid  23569) is running...

同じコマンドを使用して、すべてのサービスを個別に実行したり、すべてのサービスの状態を確認したりできます。

$ service --status-all
python is stopped
automount (pid 22457) is running...
Avahi daemon is not running
Avahi DNS daemon is not running
crond (pid  23577) is running...
gpm is stopped
hald is stopped
httpd (pid  23569) is running...
...

サービスを一覧表示するためのSysVinit、Systemd、およびUpstartのさまざまな方法

より一般的なサービス管理フレームワークを使用している場合は、次の方法を使用して各フレームワークのサービスを一覧表示できます。

システム初期化

$  ls -l /etc/init.d/ | head -10
total 220
-rwxr-xr-x 1 root root  1422 Jan 13  2009 ajaxterm
-rwxr-xr-x 1 root root  3052 Apr 20  2012 autofs
-rwxr-xr-x 1 root root  1877 Apr 13  2011 avahi-daemon
-rwxr-xr-x 1 root root  1824 Apr 13  2011 avahi-dnsconfd
-rwxr-xr-x 1 root root  1926 Feb 22  2012 crond
-rwxr-xr-x 1 root root 14291 Dec 19  2011 functions
-rwxr-xr-x 1 root root  1778 Jan  6  2007 gpm
-rwxr-xr-x 1 root root  1586 Mar  5  2011 haldaemon
-rwxr-xr-x 1 root root  5742 Dec 19  2011 halt

システム

$ systemctl list-unit-files --type=service | head -10
UNIT FILE                                   STATE   
abrt-ccpp.service                           enabled 
abrt-oops.service                           enabled 
abrt-pstoreoops.service                     disabled
abrt-vmcore.service                         enabled 
abrt-xorg.service                           enabled 
abrtd.service                               enabled 
accounts-daemon.service                     enabled 
alsa-restore.service                        static  
alsa-state.service                          static  

突然現れる

$ initctl list | head -10
avahi-daemon start/running, process 1090
mountall-net stop/waiting
nmbd start/running, process 2045
passwd stop/waiting
rc stop/waiting
rsyslog start/running, process 1088
tty4 start/running, process 1211
udev start/running, process 483
upstart-udev-bridge start/running, process 480
ureadahead-other stop/waiting

引用する

おすすめ記事