A couple of Bash tips
- Single instance
# make use of bash `set -C'
(set -C; : > $lockfile) 2>/dev/null
if [ $? -ne 0 ]; then
log_msg "$0 already running, exit"
exit 0
fi - Daemonize script
# `-d' option indicates to daemonize
if [ x"$1" = "x-d" ]; then
$0 2>&1 >/dev/null &
exit 0
fi
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home