[Linux] shell script programming - device number to send notification messages statistics log file

1. Log File List

For example: / data1 / logs / 2019/08/15 /

10.1.1.1.log.gz

10.1.1.2.log.gz

 

A keyword 2. The shell script statistics log

zcat * .gz | grep keyword | grep -oP "deviceid = [^ =] +" | uniq | sort -u> /tmp/20190815.log

formatting information such as the date date, spliced ​​into the path

wc -l /tmp/20190815.log, to get the number of rows

php /xxxxx/sendmail.php "Information"

 

3. Call PHP scripts third-party SMTP sends a notification letter

Use $ argv [1] to receive parameters

Because postfix may not be installed, you can not use the sendmail command

PHP uses phpmailer class, mainly smtp class, third-party call letters

 

4. Increase the timing task cron

8:00 every day regularly call shell script

0 8 * * * xxxxxx

 

Guess you like

Origin www.cnblogs.com/taoshihan/p/11361281.html