0

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.

2

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

  • Thanks! This was the approach I went it, was very simple to make a script. – Accatyyc Dec 8 '11 at 17:59
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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