I have a long-running server process inside a screen session on my Linux server. It's a bit unstable (and sadly not my software so I can't fix that!), so I want to script a nightly restart of the process to help stability. The only way to make it do a graceful shutdown is to go to the screen process, switch to the window it's running in, and enter the string "stop" on its control console.
Are there any smart redirection contortions I can do to make a cronjob send that stop command at a fixed time every day?
Best Answer
This answer doesn't solve the problem, but it's left here because 30+ people found it useful, otherwise I would have deleted it long time ago.
Write to
/proc/*pid of the program*/fd/0
. Thefd
subdirectory contains the descriptors of all the opened files and file descriptor0
is the standard input (1 is stdout and 2 is stderr).You can use this to output messages on the tty where a program is running, though it does not allow you to write to the program itself.
Example
Terminal 1:
Terminal 2: