Elegant logging with screen
I could use putty to open some hidden screens, but I don’t like the idea of having several unseen windows pile up in the backgound of my Windows XP, so I keep them visible. To put them to good use, I tail some – for me – important logfiles in those windows.
In the past, I used to set up putty to send the command
su - -c "tail -f /var/log/messages /var/log/syslog /var/log/auth.log"to the remote machine. I then had to enter the root-password to see the logs. Cumbersome, slow, error-prone and quite anoying in case your Internet-connection brike down several times.
screen -a -A -d -m su - -c "tail -f /var/log/messages /var/log/syslog /var/log/auth.log"
Now I have only to start the script once, do a „screen -r” and enter the password. In putty, I only habe to give „screen -r” as the command to send to the server after login and „everything is good” (tm).
I can now just reattach to the running screen-session and see all my logs without having to enter any password or restart some tools. Very cool.