I have an executable used for running Valve dedicated game servers. When it runs, it logs its status to the terminal. I want to capture this output in a file while also seeing it.
./srcds_linux -game tf +map cp_dustbowl -maxplayers 24 | tee -a mylogfile.txt
The executable runs just fine, and my terminal is populated with the server logs in real time, but when I kill the server, mylogfile.txt is empty. Is it possible that I can see the logs from the executable but that it's not actually logging to STDOUT? I'm relatively new to bash/linux scripting. I am not trying to capture STDERR, although it does at least print some of the logs I'm seeing in my terminal to mylogfile.txt, but not nearly all of them.
Another option to handle the Source Dedicated Server on Linux and to capture all of its output is to run it in a docker container, maybe using the existing image from https://github.com/Hackebein/docker-srcds .
If you use their
runcommand but omit the-tioptions, the container will attach bothSTDOUTandSTDERRbut will not attachSTDINand will not allocate a terminal - forcing the executable to output all of its stuff to the standard stream, that you can then capture.Running in a container also allows you a lot more control, such as instructing the container to log to files or syslog.