while working I start lots of gnome-terminals and do something with them. dd
on first terminal, 12 ssh sessions to a bunch of servers to do something. These sessions are finishing it's job and get disconnected for idle or because the session is closed after the command.
However, I need a script which closes unused gnome-terminal processes. I thought about softly killing all zsh processes without child processes. This will hopefully close the terminal in a clean way.
init─┬─[...]
├─gnome-terminal─┬─gnome-pty-helpe
│ ├─2*[zsh───ssh]
│ ├─zsh───dd
│ ├─zsh───pstree
│ ├─4*[zsh] <<<<
│ └─{gnome-terminal}
.
.
.
I thinking about writing a more or less simple bash script to check the running processes and end them if zsh has no child processes and no activity for 4 hours.
I am unsure
- If this is a good idea generally.
- If somebody already published a tool to do this
- If there is a way to get the child processes of zsh (without
grep
ing andawk
ing thepstree
output ;) - How I get the last activity (thought about a pre and post command in zsh)
- If there is a better way than
kill -HUP <zsh pid>
to end the processes
Thanks in advance