0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

daemon 稼働状況表示(シェルスクリプト)

Last updated at Posted at 2018-09-13

こんにちは。
指定した daemon が稼働しているか表示してみました(下記例では daemons="httpd smbd caffeinate" が動いているかどうか、およびその pid)。macOS 上で動かしました。

$ ./deamons.sh 
/usr/bin/caffeinate 7289
$ kill -9 7289
deamons.sh
# !/bin/sh
daemons="httpd smbd caffeinate"

coloring() { [ -n "$1" ] && echo $'\e[32m'${1}$'\e[0m' || echo '' }

for daemon in $daemons; do
  d=`which $daemon 2>/dev/null` && pid=`pidof $daemon` && echo $d `coloring "${pid}"` | grep '[0-9]'
done
  • なお jobs -l コマンドは、現セッションで稼働させたバックグランドジョブ(+プロセスID)を表示します。
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?