Is there any way of which anyone is aware to (1) customise the directory into which the Linux server build of Simutrans records its logs; and (2) require that the existing log file, if any, at that location is appended rather than overwritten? I am having trouble tracking down crashes on my server because the restart script causes the log file to be overwritten.
If you have a script that restarts the server, then I would recommend changing that script so that it renames the old log file first. That's a better solution than appending, as you can then open the old log in peace (it isn't written to it anymore) and find the last things that happened at the bottom (no need to search for it). As a bonus, you can also see how often and when it restarted.
Yes, I see - and presumably, the script would also need to rename the old log that it previously re-named, and so on ad infinitum...?
No, you give each log file a unique name. The easiest, and perhaps most popular way of doing that, is by including the current date and time in the file name.
Ahh, yes, I see. I have had a go at modifying the script to do this, although my shell scripting knowledge is limited, so I am not sure whether it will work.
Something like mv simu.log simu.log.`date +%FT%T` perhaps. %T means the file name will include colons. If this is a problem, a different format argument must be passed to date. See date --help for that.
What I have done is this:
now=$(date +"%d_m%_%Y")
/bin/sh -c "cp /usr/share/games/simutrans-experimental/simutrans/simu-server13353.log /var/log/old-log_$now.log"
Does this look workable to you?
Edit: Sadly, this does not seem to work, and it is not clear why.
It is the m% which should be %m. now was receiving m%y. I would include _%T at now to include the time.
Quote from: An_dz on May 12, 2014, 03:43:27 AM
It is the m% which should be %m. now was receiving m%y. I would include _%T at now to include the time.
Ahh, splendid, thank you - modified accordingly.
Best to build Simutrans with syslog support, and then manage your logs through that (most Linux systems come with logrotate or a derivative).
Hmm - how would one build Simutrans with syslog support...?
It's documented it config.template, which is the place for customizing the build (except MSVC builds, and possibly native MacOS).
Yeah, it's in config.template:
FLAGS = -DSYSLOG
...although I did look in config.default first, and could not find it. Which makes perfect sense, since I only sync config.default from config.template on rare occasions. It's one of the tripwires when having templates in VCS that needs to be copied and configured for each workspace: the file you normally use is almost never up-to-date. But configuring the file that lies in VCS is more dangerous, if you have commit rights, just for everyone else but you.
Thank you very much for this: that is most helpful. I have now amended the config.default on my server to include this, so it should be incorporated into the next build.