aboutsummaryrefslogtreecommitdiffstats
path: root/src/cron/counter.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/cron/counter.sh')
-rwxr-xr-xsrc/cron/counter.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/cron/counter.sh b/src/cron/counter.sh
new file mode 100755
index 0000000..f3a7656
--- /dev/null
+++ b/src/cron/counter.sh
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+logfile='/var/log/nginx/access.log'
+destfile='/usr/local/www/jozan/index.html'
+foretext='Unique visitors: '
+tmp=$(mktemp)
+
+sed "s/$foretext.*$/$foretext$(awk '{print $1}' $logfile | sort | uniq | wc -l | tr -d ' ')/" $destfile >"$tmp"
+cat "$tmp" >$destfile
+rm "$tmp"