5113d5028abfbbc0f241642315afb28e1307d318
[irspy-moved-to-github.git] / bin / irspy-update.sh
1 #!/bin/sh
2 #
3 # wrapper for irspy.pl
4 #
5 # run irspy with a smaller set of records in a loop to avoid out-of-memory
6 #
7
8 home=/usr/local/src/git
9 cd $home/irspy/bin || exit 2
10 logdir=../tmp
11 lockfile=../tmp/irspy-update.lock
12 : ${irspy_test=Main}
13
14 if [ -f $lockfile ]; then
15     pid=`cat $lockfile`
16     if kill -0 $pid 2>/dev/null; then
17         echo "This script is already running with pid: $pid"
18         exit 1
19     fi
20 fi
21 echo $$ > $lockfile || exit 2
22
23 weekday=`date '+%w'`
24 for i in 0 1 2 3 4 5 6
25 do
26    logfile=$logdir/irspy-mod-$i.log.$weekday
27    YAZ_LOG=irspy,irspy_test,irspy_task nice -10 time perl -I../lib irspy.pl -n 50 -d -M 3500 -f'cql.allRecords=1 not zeerex.disabled = 1' -t $irspy_test -m 7,$i localhost:8018/IR-Explain---1 > $logfile 2>&1
28
29    sleep 1 # catch ctr-c before compressing the log
30    gzip -f $logfile
31 done
32
33 rm -f $lockfile
34