element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Internet of Things
  • Technologies
  • More
Internet of Things
Blog Set up Elecrow TTN LoRaWAN gateway on Raspberry Pi - Pt. 3: manage the service log size
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Internet of Things to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 9 Jan 2024 4:48 PM Date Created
  • Views 1029 views
  • Likes 10 likes
  • Comments 2 comments
  • raspberry
  • the things network
  • lorawan
  • ttn
  • gateway
  • iot
Related
Recommended

Set up Elecrow TTN LoRaWAN gateway on Raspberry Pi - Pt. 3: manage the service log size

Jan Cumps
Jan Cumps
9 Jan 2024
Set up Elecrow TTN LoRaWAN gateway on Raspberry Pi - Pt. 3: manage the service log size

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:

image

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

image

Then, you activate the added log config:

image

If you want, you can do a first run immediately:

image

and validate if all is good:

image

image

Check the size of the log:

image

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:
image
This will avoid that you get a "log truncated" message (and any other warning)

See also: Linux commands can turn a log into structured data (turn a TTN Gatesway log into a csv) 

  • Sign in to reply
  • Jan Cumps
    Jan Cumps over 1 year ago

    Logs after 3 months continuous run. 

    image

    All resources are sill healthy. CPU, MEM and DISK. Seems this 'll be able to run "forever".

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago

    Turns out that this approach works reliable

    image

    It rotates the log weekly. The last rotated log is uncompressed (my choice). The 3 older ones compressed. Any older than that deleted.

    It's still a decent size, about 65 MB per week. But it's under control. Not an ever growing file that will fill disk space.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube