Inoku
Inoku

Reputation: 49

Send command to a nohup process?

I have a minecraft server that when I run it, takes the console and can receive commands/parameters.

I'm running it with nohup java -Xms.... -jar spigot.jar &. It will stay in the background with PID XXXX and port YYYY.

I want know if it is possible to send commands to it as /help.

Regards and thanks for the help.

Upvotes: 1

Views: 4568

Answers (2)

Inoku
Inoku

Reputation: 49

I can solved this by tripleee.

This works "nohup tail -f /usr/server/console.in | nohup java -Xms.... -jar spigot.jar >> /usr/server/console.out &"

Whit"echo command >> /usr/server/console.in"

Is as i run the command in the server.

Upvotes: 3

Bodo
Bodo

Reputation: 9855

Instead of running your server in the background with nohup java -Xms.... -jar spigot.jar & you could use a terminal multiplexer like screen.
See https://ss64.com/bash/screen.html
or https://www.gnu.org/software/screen/manual/screen.html

For interactive start, run screen first, then inside the screen session run java -Xms.... -jar spigot.jar (in the foreground, without nohup or &).
Then you can use screen's escape sequence CTRL+a d to detach from the session. Your server will continue to run.

If you later want to interact with the server, use screen -r. This will reattach your terminal to the session.
Type /help or whatever you need to do. When you are done, detach from the session again.

You could also use screen -d -m java -Xms.... -jar spigot.jar to create a detached session with your command, e.g. in a startup script.

screen has a lot more capabilities. Read the documentation.

Upvotes: 4

Related Questions