Skip to content

Instantly share code, notes, and snippets.

@oppara
Last active June 26, 2020 08:49
Show Gist options
  • Save oppara/8797939 to your computer and use it in GitHub Desktop.
Save oppara/8797939 to your computer and use it in GitHub Desktop.
cron tips
#!/bin/sh
set -eu
FILENAME=`basename $0`
SCRIPT_PID="/tmp/${FILENAME%.*}.pid"
if [ -f $SCRIPT_PID ]; then
PID=`cat $SCRIPT_PID `
if (ps -e | awk '{print $1}' | grep $PID >/dev/null); then
echo "${0##*/}: exist another instance" 1>&2
exit 1
fi
fi
echo $$ > $SCRIPT_PID
コマンド
rm $SCRIPT_PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment