#!/usr/bin/env bash set +vx # getcron - Process crontab stream entries # Usage: getcron [] # If is given, only show entries of that user # Get uncommented crontab stream entries mapfile -t lines < <(crontab -l |grep -v '^#' |grep ' *\s/var/www/stream ') #echo "User: $1" #now=$(date '+%Y-%m-%d %H:%M') for line in "${lines[@]}" do #tag=${line##* } _=${tag#*.} dt="${_:0:10} ${_:11:2}:${_:13:2}" _=${_:16} user=${_%%[@:]*} #[[ $dt > $now && $user = $1 ]] && echo "$dt $tag" read m h d M _ _ tag <<<"$line" _=${tag#*.} _=${_:16} user=${_%%[@:]*} dt=$(printf "%02d:%02d %s %d" $h $m $(date -d 2022-$M-01 +%B) $d) [[ -z $1 || $user = $1 ]] && printf "%-20s %s\n" "$dt" $tag done |sort