Many of us know the joys of the "Screen" command. I did notice that this topic became a point of many questions at the recent Ohio LinuxFest, so I thought I could touch more on it here.
Being able to detach and reattach to a shell is a wonderful thing. It is very useful when executing long query transactions like MySQL data exports or even running backups at times. It is also very useful to be able to change computers or locations and keep the same working shell environment. I often used Screen when I started a shell script that executed a full compressed backup, scp the files to a remote slave, and then would start to uncompress the backup onto the new slave. The entire process for this was around 24hrs easily so being able to reattached and monitor the progress was very helpful.
Being able to have a visual display that is quick and clear as to what host your connected on is of course critical. A fast an easy way to know MySQL Hosts is also very valuable. At the very least you can change the mysql prompt in the my.cnf file ( ie my.cnf --> mysql --prompt=" this is a mysql box>" )
or just via your session
( mysql> prompt MySQL Master> PROMPT set to 'MySQL Master> ' MySQL Master> show master status\G
Screen becomes helpful keeping the shells organized. Personally, I do not like to have a different colors in my shell backgrounds. A simple white or black is just fine for me.
Here are a few other things I do with Screen:
1st create or edit a file for yourself vi ~/.screenrc
I like to enhance my status line at the bottom with the following:
Another big advantage of Screen is being able to work with remote workers in training or just reviewing MySQL queries. For example, you can have a few different developers on the same screen session and execute explain on their recent queries so you can all review the best index options together. If you want to learn more about that here is a nice article.
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.