3
0

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.

Cron 多重起動 チェック(引数含む)

Last updated at Posted at 2019-02-14

Proccess名+引数での多重起動判定

# !/bin/bash

ARGS="${@}"

# check proccess & args
OLDEST=$(pgrep -fo "$0 ${ARGS}")
if [ "$$"= "${OLDEST}" ] && [ "$PPID"= "${OLDEST}}" ];then
   echo "$0 ${ARGS} is already running"
   exit 1
fi

同じスクリプトを引数違いで複数起動するが、それぞれの多重起動を抑止する場合に使う。
(それぞれ別名にすれば事足りるんだけど)
時々使うので備忘録。

参考URLそのままなので説明なし...

参考:
http://memo-off.blogspot.com/2015/08/cron.html
https://qiita.com/nao58/items/bdf97826a3683ccd63fb

3
0
1

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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?