Bird
0
0

You want to log temperature and humidity every minute on a Raspberry Pi and keep logs for a week. Which approach best supports this goal?

hard📝 Best Practice Q15 of 15
Raspberry Pi - Data Logging and Databases
You want to log temperature and humidity every minute on a Raspberry Pi and keep logs for a week. Which approach best supports this goal?
AOverwrite a single log file every minute with new data only.
BUse a Python script appending data to a daily log file and rotate files weekly.
CStore data only in memory without saving to disk.
DLog data once and delete logs after one hour.
Step-by-Step Solution
Solution:
  1. Step 1: Understand logging frequency and retention needs

    Logging every minute generates many entries; keeping a week requires file management.
  2. Step 2: Choose a method that appends and rotates logs

    Appending to daily files and rotating weekly keeps data organized and manageable.
  3. Final Answer:

    Use a Python script appending data to a daily log file and rotate files weekly. -> Option B
  4. Quick Check:

    Append + rotate files = best for long-term logs [OK]
Quick Trick: Append data daily and rotate files weekly [OK]
Common Mistakes:
MISTAKES
  • Overwriting logs loses past data
  • Not saving data to disk risks loss
  • Deleting logs too soon loses history

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes