I am an Ubuntu 9.04 user. Given a list of screen sessions such as the following:
9076.pts-30.moe (09/27/2009 11:30:08 PM) (Attached)
8778.pts-24.moe (09/27/2009 11:29:46 PM) (Detached)
8674.pts-0.moe (09/27/2009 11:29:25 PM) (Attached)
22649.pts-28.moe (09/27/2009 11:51:46 AM) (Detached)
22543.pts-24.moe (09/27/2009 11:50:56 AM) (Detached)
22228.pts-16.moe (09/27/2009 11:49:59 AM) (Detached)
How would I close out multiple screens based on a time criterion? For instance, all screens initiated before 12:00 PM. I normally would type:
screen -dr 22649.pts-28.moe
exit
...
and close each one out manually, but this is tedious. Thanks in advance.
Best Solution
You can send commands to a screen using the -X parameter. So you can close a screen from the command line by saying "screen -S 22649.pts-28.moe -X quit".
To select the screens by time, I guess you have to run a script to compare the times.
Personally, I would use os.popen() and time.strptime() in python.