Dienstag, 19. März 2013

Using screen(1)

Sometimes when it comes to sysadmin stuff, I don't have all the tools at hand or don't even know about them properly. I am not a sysadmin but have to do some stuff on our servers and one tool which I use more and more is screen.

I read about it at webadvent in a post by Remy Sharp and had many situations this could be handy. One where long-running commands. I was using nohup which was ok but had a few drawbacks. I could not do anything else while the command run. I also need to remember to put nohup in front of every command which would maybe run a little longer. Now using screen, I'm inside a "standard" session and if my connection cripples, I can get back where I left of in no time.

Another use case is a very basic deamon. If you run any command in screen, you can exit the screen session and the command will continue to run if the program is not at the end. I would not recommend running apache inside a screen session in production, but if you have something non-critical, you could use screen. I did it yesterday to run a command which logs i/o data. I wanted to run it for 24h and just startet it inside screen. Nice! I also use it sometimes if I need to run a python or node.js server in my development environment and don't want to block my ssh session (I ssh into a vagrant environment).

And if you are working remote, sharing a session and being able to work together on a problem is also an awesome feature. It makes working together on a server easy. It is also easy to leave the problem and let another person return, as he can take over, see what was done and has some kind of history other than the bash history which may include commands not related to the problem and often has to little information.

I think what amazes me most about screen is that it's a tool that does one thing, and it does it good. It does not want to be the only tool you need but is a tiny little thing, always there when you need it. If you want to try it check the blog post mentioned above or one of the many tutorials out there. It's very easy to use because of it's simple nature and brings real benefit.

Keine Kommentare:

Kommentar veröffentlichen