22/10
2019
#mgr.sh #!/bin/bash base_dir=$(cddirname "$0"
&& pwd) TASK_COUNT=24 MUTEX_FILE=${base_dir}/count.mutex BIN=/usr/bin/php function maybe_wait() { while : do cnt=lsof ${MUTEX_FILE} | awk '$1=="sh"' | wc -l
echo "LIMIT_TASK_COUNT: $TASK_COUNT, CURRENT: $cnt" if (( $cnt < $TASK_COUNT )); then break fi sleep 10 done } for day incat ${base_dir}/days.list
do echo "wait: $day, $hour" maybe_wait sh ${base_dir}/task.sh ${day} &> ${base_dir}/logs/${day}.log & done
#task.sh
#!/bin/bash
base_dir=$(cd dirname "$0"
&& pwd)
MUTEX_FILE=
exec 7<>${MUTEX_FILE}
if (( 1 > $# )); then
echo $0 yyyy-mm-dd
exit
fi
day=$1
echo $day