Pastebin
Paste #1772: zsh daemon
< previous paste - next paste>
Pasted by tdn
function daemon() {
name=$1
delay=$2
cmd=$3
lockfile="/tmp/$name.lck"
pidfile="/tmp/$name.pid"
touch $lockfile
(
while sleep $delay && [[ -f $lockfile ]]; do
eval $cmd
done
echo "Stopping $name"
)&
pid=$!
echo $pid > $pidfile
echo "Started $name with PID: $pid"
}
New Paste
Go to most recent paste.