Background real-time streaming file shell script _linux Shell

Source: Internet
Author: User

Copy the files under the Bill folder to a certain rule (file name parity) under the Bill1,bill2 folder.
Update BILL1,BILL2 Processing Progress tab (update File.max)
File3 is the label for the current latest file in the bill directory and will normally be updated every minute (format: 20121016122100)

Copy Code code as follows:

#!/bin/bash
#for Wanggy 2012/10/16
Bill1=/infosms/bill1
Bill2=/infosms/bill2
file_max= ' Cat File3 '
Cd/infosms/bill
While:
echo "Start"
Todo
If [$file _max!= ' cat file3 '];then
echo "Unequal, handling"
#判断file3 11-12-bit (parity)
Num1= ' cut-c 11-12 file3 '
#如果不加10 # 08 can go wrong when taking a model. (8 in-system judgment?) )
num=$ ((10# $num 1%2))
#num =$ (($num 1%2))
#获取bill下当前文件 (Latest)
File_name=b ' Cat File3 '
echo "Latest file: $file _name"
Case $num in
1)
echo "Odd"
Cp-a $file _name. /bill1
Echo ' Cat file3 ' ... /bill1/file.max

0)
echo "Even"
Cp-a $file _name. /bill2
Echo ' Cat file3 ' ... /bill2/file.max

Esac
echo "to File_max to the newest value"
file_max= ' Cat File3 '
Else
echo "Equals, does not handle, exits!" "
# file_date= ' Cat $filename '
# exit 1
Fi
echo "Wait 10 seconds, next judgment ..."
Sleep 10
Done

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.