#!/bin/bash
#pid=$(jobs -p)
#echo "pid is $(jobs -p)"
d="+[%Y-%m-%d %H:%M:%S]"
trap 'kill $(jobs -p) 0' EXIT
(
if flock -n 9; then
while true; do
echo "testjobs" ; date
sleep 3
done
fi
) 9> /var/lock/test.lock 3>&2 2>&1 | (while read ; do echo $(date "$d") "$REPLY" ; done )
网友评论