I have a bunch of servers, on which I run experiments using screen
. The procedure is the following :
ssh
to server XXX For windows system
Open putty
then login in server
If you want to see screen in Console then you have to write command
Screen -ls
if you have to access the screen then you have to use below command
screen -x screen id
Write PWD
in command line to check at which folder you are currently
I'm not really sure of your question, but if all you really want is list currently opened screen session, try:
screen -ls
Multiple folks have already pointed that
$ screen -ls
would list the screen sessions.
Here is another trick that may be useful to you.
If you add the following command as a last line in your .bashrc file on server xxx, then it will automatically reconnect to your screen session on login.
screen -d -r
Hope you find it useful.
To list all of the screen sessions for a user, run the following command as that user:
screen -ls
To see all screen sessions on a specific machine you can do:
ls -laR /var/run/screen/
I get this on my machine:
gentle ~ # ls -laR /var/run/screen/
/var/run/screen/:
total 1
drwxrwxr-x 4 root utmp 96 Mar 1 2005 .
drwxr-xr-x 10 root root 840 Feb 1 03:10 ..
drwx------ 2 josh users 88 Jan 13 11:33 S-josh
drwx------ 2 root root 48 Feb 11 10:50 S-root
/var/run/screen/S-josh:
total 0
drwx------ 2 josh users 88 Jan 13 11:33 .
drwxrwxr-x 4 root utmp 96 Mar 1 2005 ..
prwx------ 1 josh users 0 Feb 11 10:41 12931.pts-0.gentle
/var/run/screen/S-root:
total 0
drwx------ 2 root root 48 Feb 11 10:50 .
drwxrwxr-x 4 root utmp 96 Mar 1 2005 ..
This is a rather brilliantly Unixy use of Unix Sockets wrapped in filesystem permissions to handle security, state, and streams.
So you're using screen to keep the experiments running in the background, or what? If so, why not just start it in the background?
./experiment &
And if you're asking how to get notification the job i done, how about stringing the experiment together with a mail command?
./experiment && echo "the deed is done" | mail youruser@yourlocalworkstation -s "job on server $HOSTNAME is done"
In most cases a screen -RRx $username/
will suffice :)
If you still want to list all screens then put the following script in your path and call it screen or whatever you like:
#!/bin/bash
if [[ "$1" != "-ls-all" ]]; then
exec /usr/bin/screen "$@"
else
shopt -s nullglob
screens=(/var/run/screen/S-*/*)
if (( ${#screens[@]} == 0 )); then
echo "no screen session found in /var/run/screen"
else
echo "${screens[@]#*S-}"
fi
fi
It will behave exactly like screen except for showing all screen sessions, when giving the option -ls-all as first parameter.