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