I desperately despaired of debugging my script, I used some of the constructs recommended to me from my senior college, and I don’t know how to make it work correctly.
set -ueo pipefail
exec &>/tmp/dq.log
source ${BASH_SOURCE%/*}/env-prd.sh
times=${2:-1}
sleep=${3:-1}
name="all-dq_hourly"
fs_lock_file="/tmp/mwa/jobs/prd-${name}.lock"
( flock -n 200
log="/var/log/mwa/prd/$(date +%Y-%m-%d)__${name}.log"
for i in $(seq 1 $times); do
if [[ ! -f /tmp/stop ]]; then
couple commands
fi
sleep $sleep
done
) 200>"$fs_lock_file" | tee -a $log
rm $fs_lock_file
From execs, I can see that the problem with an unbound variable for the part tee -a $log
is couple commands
being fully executed. I tried to use backtics in the log path, but did not get any benefit. I suspect the same problem with the fs_lock_file file, but I have not fixed the registration yet.
Can someone open my eyes and tell me what I lost? Im not able to record the script in the specified path.
source
share