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.
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
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.