Hi all, seeing something a little strange and wondering if there is something I am missing. I am running an endurance test on my rebuilt mycodo rpi before wiring it up for real (solder, pcb, etc.). Everything is working really well and I do not yet want to stop mycodo! But it looks like my logs are going to mycodo.log.1 and not to mycodo.log, which was rotated at midnight the night before last. I searched the forum and GitHub issues and couldn’t find anything.
Here are the contents of my log directory:
tom@mycodo2:~ $ ls -al /var/log/mycodo/
drwxr-xr-x 2 mycodo mycodo 4096 Oct 29 00:00 .
drwxr-xr-x 9 root root 4096 Oct 24 11:50 …
-rw-r–r-- 1 mycodo mycodo 342 Oct 24 12:05 login.log
-rw-r–r-- 1 mycodo mycodo 1530 Oct 30 05:46 mycodobackup.log
-rw-r–r-- 1 mycodo mycodo 1085612 Oct 28 10:58 mycododependency.log
-rw-r–r-- 1 mycodo mycodo 45246 Oct 24 12:05 mycodoimport.log
-rw-r–r-- 1 mycodo mycodo 0 Oct 24 11:50 mycodokeepup.log
-rw-r–r-- 1 mycodo mycodo 0 Oct 29 00:00 mycodo.log
-rw-r–r-- 1 mycodo mycodo 99101387 Oct 30 05:53 mycodo.log.1
-rw-r–r-- 1 mycodo mycodo 2998106 Oct 28 08:33 mycodo.log.2.gz
-rw-r–r-- 1 mycodo mycodo 2948362 Oct 27 06:05 mycodo.log.3.gz
-rw-r–r-- 1 mycodo mycodo 2604581 Oct 26 05:34 mycodo.log.4.gz
-rw-r–r-- 1 mycodo mycodo 1929027 Oct 25 06:05 mycodo.log.5.gz
-rw-r–r-- 1 mycodo mycodo 0 Oct 24 11:50 mycodorestore.log
-rw-r–r-- 1 mycodo mycodo 35804 Oct 28 10:50 mycodoupgrade.log
This is completely normal log rotation. Log rotation is used to manage log files… after they reach a certain size they are compressed, after they reach a certain age they are deleted. This prevents the log files from eventually filling up the storage media.
Yes, that’s how log rotation works. But as I have seen it, once it happens, the .1, .2, etc files are then no longer active and .log is appended until it either reaches a size or a time elapses.
In this case, mycodo.log is zero bytes and mycodo.log.1 continues to be the active one.
I have not seen that pattern before.
Are you sure that’s normal, @Lucid3y3 ?
Thanks for the response.
I have no idea how Kyle setup the log file configs. The question I have is why are you even messing around with the log files from the CLI? You are most likely going to cause a problem by trying to access root-locked files while they are opened by the OS.
It’s OK, I am an experienced Unix user and I don’t think tailing the logs from the command line is going to hurt anything. But I went to tail mycodo.log and discovered it was empty, so here we are.
Thanks for your concern.
Yes, grep, tail, or cat are fine for parsing logs as read-only, but a text editor or anything that might write to those files while they are also being written to by the OS or Mycodo might cause issues.
It’s not uncommon to see a 0 byte-size on a log file, it just means that file has been recently created and/or the file simply hasn’t been written to yet.
You say you are “running an endurance test” on the Pi… do you actually have any Inputs, Outputs, or Functions running in Mycodo? If not, then there isn’t going to be a lot being written to that specific log file.
Again, I don’t know exactly how Kyle has the logging system configured for Mycodo logs. Maybe take a look at those configuration files and see how the logs are being managed. But like I said, I’ve never noticed any issues with how Mycodo logs work. If you can read the logs from the Logs page in the Mycodo web-gui, then I would assume the logs are working as intended.
Well, it turns out that this issue solved itself when I had to reboot the pi. Given the amount of screwing around I am doing, I don’t think it is worth another thought unless it recurs and becomes a problem. Thanks, @Lucid3y3 for weighing in.
I let logrotate handle maintaining the log files. There’s likely some issue with closing the file before it’s renamed and the renamed file continues to be written to. I’m not very familiar with logrotate, but if you have an interest in running some tests, you could edit the logrotate config (below), then rerun
sudo mycodo-commands update-logrotate to copy the new config, and reboot for it to take effect.
Thanks, @KyleGabriel - if it happens again, I’ll try to replicate it. I was running an endurance test with some long-distance i2c stuff and I have changes to the underlying OS without restarting mycodo or the Pi. I’m leaving well enough alone, haha.