Skip to content

Instantly share code, notes, and snippets.

@koki-h
Created November 30, 2015 12:46
Show Gist options
  • Select an option

  • Save koki-h/ec00fe0b683a36262daf to your computer and use it in GitHub Desktop.

Select an option

Save koki-h/ec00fe0b683a36262daf to your computer and use it in GitHub Desktop.
2重起動させないための起動スクリプト(pgrepを使う版)
#!/bin/bash
if [ $$ -ne $(pgrep -fo "$0") ]; then
echo "実行中。2重起動を禁止しています。"
exit 1
fi
trap 'kill $(jobs -p);echo 強制終了されました。' EXIT
#処理本体
./hogehoge.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment