From The Compiler, 5 Years ago, written in Bash.
This paste is a reply to killmosh from The Compiler
- view diff
Embed
  1. #!/bin/bash
  2. who | sed -n 's/^[^ ]* *[^ ]* *\([^ ]* [^ ]*\) (mosh \[\([0-9]\{1,5\}\)\])$/\1 \2/p' | while read d t pid; do
  3.     epoch=$(date -d "$d $t" '+%s')
  4.     thresh=$(date -d "2 days ago" '+%s')
  5.     if (( epoch < thresh )); then
  6.         kill "$pid"
  7.     fi
  8. done