select distinct a.sessionid||'.wav' from tbl_gl_call_info a where a.parentuid='__project_ID' and to_number(to_char(a.incomingtime, 'YYYY'))=2013 and to_number(to_char(a.incomingtime, 'MM'))=04 and (a.finalstage='operator' or a.finalstage='redirect')
Project_1 project1code Project_2 project2code
#!/bin/bash ################################################## # (cc) 2013 by Sergey Kirgizov (skirgizov@ya.ru) # ################################################## # year=`date +%Y` if [[ ! "$1" || ! "$2" ]]; then echo ": report.sh YYYY MM" exit fi if [[ "$1" -lt "2012" || "$1" -gt "$year" ]]; then echo " 2012 $year" exit fi if [[ "$2" -lt "01" || "$2" -gt "12" ]]; then echo " . 01 12" exit fi # wdir="/home/user/report" # user=user # NPO pass=password # dbase="url.to.database:port/databasename" # URL conf_lines=`cat $wdir/etc/projects.conf | wc -l` let "conf_lines += 1" # wc , 0 . i=0 # rm -rf $wdir/data/* rm -rf $wdir/export/* # while [ "$i" -lt "$conf_lines" ] do let "i += 1" project=`cat $wdir/etc/projects.conf | head -n$i | tail -n1 | awk '{print $1}'` code=`cat $wdir/etc/projects.conf | head -n$i | tail -n1 | awk '{print $2}'` echo "select distinct a.sessionid||'.wav' from tbl_gl_call_info a where a.parentuid='$code'" > $wdir/data/waw.sql echo "and to_number(to_char(a.incomingtime, 'YYYY'))=$1 and to_number(to_char(a.incomingtime, 'MM'))=$2" >> $wdir/data/waw.sql echo "and (a.finalstage='operator' or a.finalstage='redirect');" >> $wdir/data/waw.sql echo "exit;" >> $wdir/data/waw.sql sqlplus -S $user/$pass@$dbase @$wdir/data/waw.sql | grep nauss > $wdir/data/"$project".lst # "grep nauss", sqlplus'a done i=1 # while [ "$i" -lt "$conf_lines" ] do project=`cat $wdir/etc/projects.conf | head -n$i | tail -n1 | awk '{print $1}'` code=`cat $wdir/etc/projects.conf | head -n$i | tail -n1 | awk '{print $2}'` FILES=`cat $wdir/data/"$project".lst` mkdir $wdir/export/$project echo -n " $project..." n=0 for file in $FILES do let "n += 1" find /opt/naumen/nauphone/spool/naubuddyd/mp3/$1/$2 -name $file -exec cp {} --parents --target-directory=$wdir/export/$project/ \; done mv $wdir/export/$project/opt/naumen/nauphone/spool/naubuddyd/mp3/$1/$2/* $wdir/export/$project/ # rm -rf $wdir/export/$project/opt # echo " $n ." let "i += 1" done
#!/bin/bash # wdir=/home/user/report # year=`date +%Y` # month=`date --date "1 month ago" +%m` # SUBJECT=" $month ." # EMAIL="mail@mailserver.com" # ( ) EMAILMESSAGE="$wdir/msg.txt" # # echo " $month $year ." > $EMAILMESSAGE $wdir/report.sh $year $month >> $EMAILMESSAGE # /bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE #
0 1 1 * * /home/user/report/report.sh
Source: https://habr.com/ru/post/178799/
All Articles