Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)
^C
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
add comment

2 Answers

up vote 1 down vote accepted

You can send remote command to an existing screen session with the -X option. This StackOverflow post should help: http://stackoverflow.com/questions/6064548/send-commands-to-a-gnu-screen

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
add comment

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
add comment

Your Answer

 
discard

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.