From babbae0f6f2dd9d8744ff442595e751a24809acc Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 18 Apr 2022 02:50:08 +0200 Subject: New script to count visitors on my website --- src/cron/counter.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 src/cron/counter.sh (limited to 'src/cron/counter.sh') 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" -- cgit v1.2.3