How to give realtime input to a background process?
So basically what is happening is I will start a process from a script. In this case the process is a Minecraft server, which is a java application. When I start it normally, my terminal will stay connected to the process, and I can enter commands to the application, like "stop" or "list users".
So, when I've started this application from a script, I don't have it open in a terminal to give it input, is there any way to 're-open' it, so me (or another script), could give this application commands? Ideally, I'd also be able to read the output it gives immediately after I give it a command. I've heard I could use screen to do this, but is there any more elegant way? Screen seems a bit roundabout. |
I recently read the dd man page for running dd in the background. It mentions running the following kill command to bring it into the foreground and print out statistics of it and let it continue (does not kill it).
Code:
kill -USR1 pid The kill man page mentions the -USR1 switch but does not specify what it is used for. So I still need to research more into it. SAM |
Based on my very limited knowledge of the topic, that actually sounds brilliant.
It's my understanding that when a process goes to the background, it forks off, and runs under user id 1, and kills the old process. So, it looks like this is just killing the process under UID 1, and restoring it. That's pretty sweet. Could do that in a script, and then give input to (what I think is) it's STDIN? Edit: I'll give it a try before decrying it, but it looks like this is merely sending it a "User Defined Signal", and according to wikipedia, dd behaves notably in this manner, and it's unclear what this will do to other applications. http://en.wikipedia.org/wiki/SIGUSR1 |
Does normal process control not work for you?
e.g. Code:
somecommand & Edit: I just reread your first post and saw you already discussed screen. You can pretty much disregard this post but I'll leave it up for archival purposes. |
Yeah looks like I have to use screen. (Just figured I'd post in case someone stumbles upon this thread in the future)
|
All times are GMT -5. The time now is 03:33 PM. |