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 5 years have passed since last update.

bashでサーバ起動、停止sh

Posted at

起動sh

起動時にプロセスIDを補足して、ファイルに吐き出す。

# !bin/bash
#
起動コマンド &
pid=$!
touch $pid.pid 

停止sh

*.pidファイルを特定し、それでkillする。その後pidファイルを削除する。
当然、ゴミが残っている状況は想定しない。

# !bin/bash
#
pidFile=`ls *.pid`
pid=${pidFile%.*}
echo $pid stop server
kill $pid
rm -rf $pidFile
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?