In part 1, Set up Elecrow TTN LoRaWAN gateway on Raspberry Pi - Pt. 1: build and test , I compiled the software for the Elecrow LoRaWAN gateway (see Low-Cost LoRaWAN Gateways! ), and enabled the gateway on The Things Network (TTN). I used Raspberry OS bullseye 32-bit lite on a Raspberry Pi A+. I tested this on a B+ with the same OS too. In part 2, Set up Elecrow TTN LoRaWAN gateway on Raspberry Pi - Pt. 2: full install and run as service , the software gets properly installed, and I configure it as a systemd service. In this 3rd post, a cleanup activity: manage the service's log file size.
The log of the forwarder service can grow with several MB per day. If this is unmanaged, the Raspberry Pi will run out of disk space. You can check the size by running:
Raspberry OS has a mechanism to handle log files: logrotate. This command is executed regularly, and can archive or delete logs. The utility is set up to handle several of the standard logs. Packages can add their log management, by adding a file to /etc/logrotate.d
sudo nano /etc/logrotate.d/lora_pkt_fwd
Then, you activate the added log config:
If you want, you can do a first run immediately:
and validate if all is good:
Check the size of the log:
If all is good, the system should now automatically weekly archive the log file, and keep the 4 latest archives.
When you use tail & grep to monitor the devices that are connecting, you may want to adapt the monitor command to filter out warnings when the log cycles: |
See also: Linux commands can turn a log into structured data (turn a TTN Gatesway log into a csv)