0

So I have a Minecraft server that is being hosted on Google Cloud Platform. To start the server I use the command

java -Xmx1024M -jar spigot.jar -o true

When I used this command to launch the server it would show me the server logs (people connecting/disconnecting, etc.) but the problem was that when I used that command to launch, whenever I would exit out of the SSH in GCP it would shut down the server. To fix it I started running the server in the background using the command

nohup java -Xmx1024M -jar spigot.jar -o true &

After using this command I don't see the server logs anymore. I know that in Ubuntu/Linux you can store Java output on a file (ex: .txt file).

The Question: Say I create a file called logs.txt, with what command can I save the server logs onto that .txt file?

I'm a newbie with bash/linux (you can probably tell) so all help is greatly appreciated!

Happy New Year!

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Vish G
  • 25
  • 1
  • 6

1 Answers1

0

Did you try to append the output to a file?

nohup java -Xmx1024M -jar spigot.jar -o true >> out.txt&

or

nohup java -Xmx1024M -jar spigot.jar -o true > out.txt&

When using > will append the text to end of existing out.txt file.

When using > will replace the existing out.txt file.

Prathibha Chiranthana
  • 822
  • 1
  • 10
  • 28
  • I'll give it a try. Also, do you know if there is a way that I can have it create a new .txt file every time I launch it?? – Vish G Jan 03 '21 at 06:33
  • U can use a linux command which is using date-time such as "$(date +"%Y_%m_%d_%I_%M_%p").log https://unix.stackexchange.com/questions/278939/how-do-you-put-date-and-time-in-a-file-name – Prathibha Chiranthana Jan 04 '21 at 03:58