#!/bin/bash
LOCKFILE=/tmp/lock.txt
OnlyProcess() {
#The signals listed below may be available for use with kill.
#When known constant, numbers and default behavior are shown.
#Name Num Action Description
#0 0 n/a exit code indicates if a signal may be sent
if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
echo "already running"
exit
fi
# make sure the lockfile is removed when we exit and then claim it
trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
echo $$ > ${LOCKFILE}
}
OnlyProcess
sleep 1000
阅读(1111) | 评论(0) | 转发(0) |