5

Is it possible to stop all applications to write to /var/log/? I feel like the writing causes my sd-card to break fast. If it were possible to have them write to /dev/shm/ it would be great, this way I could access them while running + they wouldn't write on my sd-card.

Legatio
  • 181
  • 2
  • 5

2 Answers2

8

So, you can turn off most logging completely by just disabling the rsyslog service by editing rsyslog.conf. This I'm sure has been answered many times before on here.

As someone who logs a lot of information for a Pi server 24/7, my microSD's are fine using programs like log2ram, which will write to RAM instead until some interval/condition you set to make an actual write to the card, for example once per day, resulting in significantly reduced write activity.

You can also use a USB drive as a more reliable and wear-proof location for log writing, or maybe just boot your Pi off the USB itself in the first place.

Here is a slick write-up of how one user accomplished logging to RAM on Raspbian 8.0 Jessie. They also show you how to determine what logs are the most active/write most frequently, and how to change the location of where all services actually save logs. This information you can use to pursue either solution.

cnrcbr
  • 108
  • 11
0

You can put then on tmpfs. This is what I have in my /etc/fstab

# Added 4 lines to use RAM instead of SSD for temp and log files
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0
tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0

Or you can use log2ram. A decent guide to how to set it up can be found at: https://pimylifeup.com/raspberry-pi-log2ram/ The github https://github.com/azlux/log2ram

craigevil
  • 21
  • 4
  • What is the difference between putting them on tmpfs and log2ram? Is the outcome the same? Is there any reason to use log2ram over this method? – Legatio May 17 '21 at 06:03
  • No real difference. But log2ram does write the logs to disk, where as using tmpfs the logs are gone when you reboot because they are just in tmpfs. – craigevil May 17 '21 at 18:20