summarylogtreecommitdiffstats
path: root/another-minute.sh
diff options
context:
space:
mode:
Diffstat (limited to 'another-minute.sh')
-rwxr-xr-xanother-minute.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/another-minute.sh b/another-minute.sh
new file mode 100755
index 000000000000..bc7068e8b0be
--- /dev/null
+++ b/another-minute.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+DATE_TIME="$(date +'%F.%u %_H:%M')"
+DATE="${DATE_TIME%% *}"
+TIME="${DATE_TIME##* }"
+HOUR="${TIME%%:*}"
+MINUTE="${TIME##*:}"
+
+LINE="$(($HOUR + 1))"
+
+LOGDIR="/var/log/usage"
+LOGFILE="$LOGDIR/$DATE"
+
+[ -d "$LOGDIR" ] || mkdir -p -- "$LOGDIR"
+
+[ -f "$LOGFILE" ] ||
+ dd if=/dev/zero bs=1 count=$((24*60)) 2> /dev/null | tr '\0' '.' | fold -w 60 > "$LOGFILE"
+
+sed -i -E "${LINE}s/^(.{$MINUTE})./\1#/" "$LOGFILE"
+