source: trunk/DataCheck/Monitoring/InsertSchedule.sh@ 18932

Last change on this file since 18932 was 18738, checked in by Daniela Dorner, 8 years ago
improved logging
  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/bash
2
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6
7# get dates
8if [ "$certaindate" != "" ]
9then
10 getdates $certaindate
11else
12 if [ "$1" = "" ]
13 then
14 # the day after tomorrow
15 dates=( `date +%Y/%m/%d --date="+1day" --utc` )
16 else
17 getdates $1
18 fi
19fi
20
21
22
23for date in ${dates[@]}
24do
25 printprocesslog "INFO insert schedule for the night of "$date
26 #echo "INFO inserting schedule for the night of "$date
27 date2=`echo $date | sed -e 's/\//-/g'`
28 year=`echo $date | cut -c 1-4`
29 month=`echo $date | cut -c 6-7`
30 day=`echo $date | cut -c 9-10`
31 query="SELECT u FROM calendar.Data WHERE y="$year" AND m="$month"-1 AND d="$day" AND u NOT IN ('ETHZ','TUDO','ISDC','UNIWUE')"
32 printprocesslog "DEBUG "$query
33 #echo "DEBUG "$query
34 shifters=`sendquery`
35 if [ "$shifters" = "" ]
36 then
37 printprocesslog "INFO No shifter found in calendar -> Do not insert a schedule."
38 echo "INFO No shifter found in calendar -> Do not insert a schedule."
39 continue
40 else
41 checkshifter=`echo $shifters | grep moon`
42 if [ "$checkshifter" != "" ]
43 then
44 printprocesslog "INFO Full moon night -> Do not insert a schedule."
45 #echo "INFO Full moon night -> Do not insert a schedule."
46 continue
47 fi
48 fi
49
50 printprocesslog "DEBUG /home/fact/FACT++.dbg/makeschedule --config /home/fact/makeschedule_gate.rc --date $date2 --enter-schedule-into-database true 2>/dev/null | grep 'Schedule entered successfully into database.\|Schedule not empty.'"
51 #echo "DEBUG /home/fact/FACT++.dbg/makeschedule --config /home/fact/makeschedule_gate.rc --date $date2 --enter-schedule-into-database true 2>/dev/null | grep 'Schedule entered successfully into database.\|Schedule not empty.'"
52 check=`/home/fact/FACT++.dbg/makeschedule --config /home/fact/makeschedule_gate.rc --date $date2 --enter-schedule-into-database true 2>/dev/null | grep 'Schedule entered successfully into database.\|Schedule not empty.'`
53 case $check in
54 "Schedule entered successfully into database.")
55 printprocesslog "INFO schedule for "$date2" successfully inserted. "
56 ;;
57 "Schedule not empty.")
58 printprocesslog "WARN schedule for "$date2" not empty -> cannot insert schedule."
59 ;;
60 *)
61 printprocesslog "ERROR problem with inserting schedule for "$date" ("$check")"
62 ;;
63 esac
64done
65
66finish
Note: See TracBrowser for help on using the repository browser.