- Linux Training
- Desktop Tutorials
- Server Tutorials
|Automatic Logouts with Screen|
|Server - CentOS|
yum install -y screen
Edit the /etc/profile which impacts all users.
Place this line at the top of the file to ensure the functioning of the file.
trap "" 1 2 3 15
At the bottom of the same file add these lines. When a user logs in they will get a message that login will complete in 5 seconds. You can adjust that time with the sleep time.
if [ -w $(tty) ]; then
trap "exec $SCREENEXEC" 1 2 3 15
echo -n 'Starting session in 5 seconds'
You will also need to modify the /etc/screenrc file and add these lines at the end.
idle 300 quit
Those settings provide a logout after 300 seconds of idle time. Modify that setting to one that makes sense for you. When you are logged in you will see the screen process.
root 4566 0.0 0.0 4924 996 pts/1 Ss+ 11:07 0:00 screen
root 4593 0.0 0.0 5056 1184 ? Rs 11:07 0:00 SCREEN
When the login is inactive for the time period indicated in the idle line, the login is automatically closed.
Last login: Mon Dec 19 10:57:13 2011 from 192.168.5.103
Starting session in 10 seconds[screen is terminating]
Connection to 192.168.5.98 closed.