Skip to main content
Topic: bash script to test test the atd daemon (Read 847 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

bash script to test test the atd daemon

After encountering problems with at-3.2.4-1.1 in armtix I wrote this bash script to test the at and atd behaviour. It sets up a delayed command for 1 minute from now and waits to see if the command succeeds

Code: [Select]
#!/bin/bash
#set up colors
case "$LANG" in
*[uU][tT][fF]-8|*[uU][tT][fF]8)
RED="\xE2\x9C\x95 "
GRN="\xE2\x9C\x94 "
;;
esac
if [ -t 1 ]; then
ncolors="`tput colors`"
if [ -n "$ncolors" -a "$ncolors" -ge 8 ]; then
RED="\e[1;31m${RED}"
GRN="\e[1;32m${GRN}"
END="\e[0m"
OWR="\e[1A\e[K"
fi
fi
OUT=/tmp/atd-test-$$.out
trap "rm -f $OUT" EXIT
cat /dev/null > "$OUT"
chmod 666 "$OUT"
lim=${1:-1}
echo "date >> $OUT" | at now + $lim min
echo -e "${RED}waiting${END}"
lim=$((lim*60 + 65)) #limit waiting
i=0
while [ ! -s "$OUT" ]; do
echo -e "${OWR}${RED}$(date) waiting${END}"
sleep 1
i=$((i+1))
((i>lim)) && echo -e "${OWR}${RED}job execution failed after $lim seconds${END}" && exit 1
done
echo -e "${OWR}${GRN}$(<$OUT) read OK${END}"