Two shell scripts every day

1 Requirements:

Please generated in accordance with such a date format (xxxx-xxxx) a daily file, for example, today's generation of file) 2017-07-05.log, and the use of disk writes to the file, (regardless of cron, you can just write a script)

#!/bin/bash
day=`date +%F`
mkdir /var/log/disk
df -h > /var/log/disk/$day.log

2. Log 1.log, reads as follows:

Log snippet:

112.111.12.248 – [25/Sep/2013:16:08:31 +0800]formula-x.haotui.com “/seccode.php?update=0.5593110133088248″ 200″http://formula-x.haotui.com/registerbbs.php” “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;)”

61.147.76.51 - [25 / Sep / 2013 : 16: 08: 31 +0800] xyzdiy.5d6d.com "/attachment.php?aid=4554&k=9ce51e2c376bc861603c7689d97c04a1&t=1334564048&fid=9&sid=zgohwYoLZq2qPW233ZIRsJiUeu22XqE8f49jY9mouRSoE71" 301 "http: // xyzdiy. 5d6d.com/thread-1435-1-23.html "" Mozilla / 4.0 (compatible ; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) "
requirements: the statistics of each views of IP how much?

awk '{print $1}' 1.log | sort -n |uniq -c|sort -n
发布了118 篇原创文章 · 获赞 33 · 访问量 2万+

Guess you like

Origin blog.csdn.net/qq_37369726/article/details/104245716