Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some server software running within a screen on a Linux (Debian if that matters) server. Every now and then I need to input some commands to the process so I want to keep it in the screen for easy access. (Also for viewing its latest output which is not logged, and it doesn't need to be.)

Sometimes this software needs to be restarted, and I do that the following way:

screen -r (to enter the screen running the software)
serversoftware -flags
^A-D (to "minimize" the screen)

And now to the problem. I need to make a simple web page with a "restart" button that restarts this server. Is there any way I can use PHP exec to mimic the above process? Letting PHP run a script file in any other language is also an option. I am though not sure how to let other processes manage a screen.

share|improve this question
up vote 2 down vote accepted

You can send remote command to an existing screen session with the -X option. This StackOverflow post should help:

share|improve this answer
Thanks! This was the approach I went it, was very simple to make a script. – Accatyyc Dec 8 '11 at 17:59

Look at rtorrent init script. It can start|stop|restart screen session with rtorrent inside. Seems to me, that all you need is just to substitute "rtorrent" on your command.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.