How to run a program and get its PID in the background
- by Ivan
I have a Minecraft server startup script that looks like this:
#!/bin/bash
cd "$(dirname "$0")"
exec java -Xmx4096M -Xms4096M -jar minecraft_server.jar
How do I get java process's PID while being able to enter input into the Java process?
if I change the exec line to
exec java -Xmx4096M -Xms4096M -jar minecraft_server.jar & echo $! > pid
it won't let me input any text into the Minecraft server java process.