Reducing writes by redirecting writes to /dev/null

This is a perl script that I use to take all the logs located in “/var/log” and redirect the output to /dev/null. This helps reduce the number of writes to the SSD card. This will help the SD card last much longer.

Save this as log.pl
——–
#!/usr/bin/perl
$log=”/var/log/”;
@array=( ‘ssl_request_log’, ‘pacman.log’, ‘named.log’, ‘mail.log’, ‘fail2ban.log’, ‘error_log’, ‘access_log’, ‘auth.log’, ‘crond.log’, ‘daemon.log’, ‘errors.log’, ‘everything.log’, ‘faillog’, ‘kernel.log’, ‘messages.log’, ‘packman.log’, ‘syslog.log’, ‘user.log’);
@array2=@array;
sub sh { my $comm =”@_[0]”; open (command,”$comm |”);
while() { } }
foreach(@array) { sh(“rm -f $log$_”); }
foreach(@array2) { sh(“ln -s /dev/null $log” . $_); }
——–

# perl log.pl