Shell to determine whether the stream file under the batch directory is processing complete

Source: Internet
Author: User

#!/bin/bash

Log_error () {
? ? ECHO-E $target date "+%Y-%m-%d %H:%M:%S" ["\033[31merror\033[0m"]: [email protected]
? ? ECHO-E $target date "+%Y-%m-%d %H:%M:%S" ["\033[31merror\033[0m"]: [email protected] >> $LOG _file
}

Log () {
? ? ECHO-E $target date "+%Y-%m-%d %H:%M:%S" : [Email protected]
? ? ECHO-E $target date "+%Y-%m-%d %H:%M:%S" : [email protected] >> $LOG _file
}

Base_dir=/home/iflytek/invoice
Scriptpath= "$ (CD" $ (dirname "$") "; pwd-p)"
log_file= $SCRIPTPATH/runscript.log
dir6_start_conf= $SCRIPTPATH/dir6_start.conf
dir6_run_conf= $SCRIPTPATH/dir6_run.conf
dir6_stop_conf= $SCRIPTPATH/dir6_stop.conf
dir8_start_conf= $SCRIPTPATH/dir8_start.conf
dir8_run_conf= $SCRIPTPATH/dir8_run.conf
dir8_stop_conf= $SCRIPTPATH/dir8_stop.conf
Out_dir=/home/iflytek/out
In_dir=/home/iflytek/in
Result_dir=/home/iflytek/result;
lock_file= $SCRIPTPATH/script.lock
done_file= $SCRIPTPATH/script.done

#$ (cat $DIR 6_start_conf);
#$ (cat $DIR 8_start_conf);

#is_lock?
If [-f $LOCK _file]; Then
? ? ? ? ? ? Log locking, is the operation.
Exit
Else
?? Touch $LOCK _file
Fi

if [!-f $LOG _file]; Then
Touch $LOG _file;

Fi

if [!-F $DIR 6_start_conf-o!-F $DIR 6_stop_conf?-o!-f $DIR 8_start_conf-o?!-f $DIR 8_stop_conf]; Then
RM-RF $LOCK _file
Exit
Fi

if [!-F? $DIR 6_run_conf?]; Then
echo $ (cat $DIR 6_start_conf) > $DIR 6_run_conf
Fi

if [!-F? $DIR 8_run_conf?]; Then
echo $ (cat $DIR 8_start_conf) > $DIR 8_run_conf
Fi

if [!-D $RESULT _dir]; Then
? ? Mkdir-p $RESULT _dir
Fi

function Diradd () {

If [$ (cat $DIR 8_run_conf)-gt $ (cat $DIR 8_stop_conf)]; Then
? ? ? ? ? ? ? ? ? ? ? ? echo $ (cat $DIR 8_start_conf) > $DIR 8_run_conf;
? ? ? ? ? ? ? ? ? ? ? ? Echo $ (($ ($ (cat $DIR 6_run_conf) +1) > $DIR 6_run_conf;
RM-RF $LOCK _file
Exit
Fi

If [$ (cat $DIR 6_run_conf)-gt $ (cat $DIR 6_stop_conf)]; Then
? ? ? ? ? ? ? ? ? RM-RF $LOCK _file
?????????????
Fi

if [!-D $BASE _dir/$ (cat $DIR 6_run_conf)/$ (cat $DIR 8_run_conf)]; Then

? ? Echo $ (($ ($ (cat $DIR 8_run_conf) +1) > $DIR 8_run_conf;
Diradd
Else
Dir_6= "$ (cat $DIR 6_run_conf)"
Dir_8= "$ (cat $DIR 8_run_conf)"

#cleaning Rubish tran_process_num=0 for one in $OUT _dir/* do filename=${one##*/} If [-F $one/F . tran.new] && [!-f $one/f.tran.done]; Then tran_process_num=$[$tran _process_num+1] elif [-f $one/f.tran.done]; Then TAR-ZCF $RESULT _dir/$filename. tgz $one/*.txt rm-rf $one Log already tran done, Gen        Erate the file: $RESULT _dir/$filename. tgz, delete unused record file: $one! Fi done parse_process_num=0 for one in $IN _dir/* do if [-f $one/f.parse.new] && [!- f $one/f.parse.done]; Then parse_process_num=$[$parse _process_num+1] elif [-f $one/f.parse.done];            Then log already parse done, delete!        Rm-rf $one fi done CD $IN _dir; num=$ (' ls-l |grep "^d" |wc-l ')) if [$NUM GT 4];        Then RM-RF $LOCK _file exit fi cd $OUT _dir; num=$ (' ls-l |grep ' ^d ' |wc-l ')) if [$NUM GT 4]; Then RM-RF $LOCK _file exit fi #iterate mkdir $IN _dir/${dir_6}_${dir_8} to Dir_4 in? $BASE _dir/${dir_6}/${dir_8}/* do????

? ? ? ? CP $dir _4/*.wav $IN _dir/${dir6}${dir_8}

    done    echo -e -n "version=taiping_ds" > $IN_DIR/${DIR_6}_${DIR_8}/f.parse.new.tmp    mv $IN_DIR/${DIR_6}_${DIR_8}/f.parse.new.tmp $IN_DIR/${DIR_6}_${DIR_8}/f.parse.new    end_time=`date ‘+%s‘`    echo ${DIR_6}_${DIR_8} >? $DONE_FILE    echo $(($(cat $DIR8_RUN_CONF)+1)) > $DIR8_RUN_CONF    rm -rf $LOCK_FILE    exit

Fi

}

Diradd

Shell to determine whether the stream file under the batch directory is processing complete

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.