Month: April 2014

The Root of Missing Mail

Like all conscientious system administrator I like to keep tabs on my servers.  One way of doing this is checking root’s email daily.  This is a great idea if you have a few servers and never take vacation!  I manage close to 100 servers, so I need a more efficient way of “hearing” my servers when they complain to root about something.  Aside from monitoring solution (not covered here) the best way to do this is to redirect where email for the root user gets sent.

This seems pretty simple so I never thought of posting about this, until today.  Some facts , to forward mail for the root user leverage the /etc/aliases file.  Like always I added a line to /etc/aliases like this:

# vi /etc/aliases

     root:    myemailaddress@uconn.edu

Ideally you want to set the email address to a list serve so that your backup administrator receives these messages also, so you can take a vacation.

I made that change yesterday on a new server and didn’t give it a second thought.  Today no mail, and I know there was an error on the system?!

First thing I checked was if I could send mail from the server, I could have…or I just forgot because I am sleep deprived…  I was able to send mail from the command line to an email address but not to an alias.  OK, that is a big clue.

While I have never had to do this before, (perhaps I restarted all my other systems?), regardless to fix the problem I simply ran this command:

# newaliases

Bingo, mail started flowing!

If that doesn’t fix it for you, other things to check are:

– Include the following in your /etc/hosts.allow:

ALL: 127.0.0.1 : allow

 

Recursive Gzip Sometimes Helps

Everyone knows that gzip’ing a file will usually make it smaller, but gzip’ing it again will not. In other words, once you’ve compressed a file, it won’t compress further.   But here’s an exception.

If you make a file of identical bytes, it can be gzip’ed several times and still become smaller.  In the example below, we made a 2GB file which consisted of identical bytes, all equal 0.  The first compression reduced the size by a factor of 1024.  The second by a factor of 602.  Next, by a factor of 14.  The next compression, not shown, grew the file by about 20 bytes.  The total compression, over the three generations, was a factor of 9,023,041 !

> dd if=/dev/zero of=2gb.zero bs=1024576 count=2048
> gzip -c 2gb.zero       > 2gb.zero.gz
> gzip -c 2gb.zero.gz    > 2gb.zero.gz.gz
> gzip -c 2gb.zero.gz.gz > 2gb.zero.gz.gz.gz
> ls -lh 2gb.zero
2.0G  2gb.zero
2.0M  2gb.zero.gz
3.4K  2gb.zero.gz.gz
328B  2gb.zero.gz.gz.gz