Last active
May 18, 2020 14:36
-
-
Save seansaito/395457091cbb9b745f61d546dec80a03 to your computer and use it in GitHub Desktop.
Remove tmux sessions older than a specific date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Usage: ./rm_tmux.sh 2020-01-01 | |
| tmux ls | tr -d '()' | awk -v dateA=$1 '{ | |
| cmd ="date \"+%Y-%m-%d\" -d \""$6" "$7" "$8" "$9"\"" | |
| cmd | getline dd | |
| if (FNR>1 && dd<=dateA) { | |
| print $1 | |
| } | |
| close(cmd) | |
| }' | tr -d ':' | while read line | |
| do | |
| echo "killing $line" | |
| tmux kill-session -t $line | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment