0

I sysadmin a multiplayer game at CentOS 6.5 Linux server for a customer.

The customer has requested me to send the daily chat logs (to identify and ban agressive players) - as a text file attachement.

So I have come up with the following crontab command:

CONTENT_TYPE="text/plain; charset=utf-8"
[email protected]
LANG=en_US.UTF-8
#minute hour    mday    month   wday    command

55      23      *       *       *       
grep CHAT /var/log/game-`date +\%a`-*.txt | 
(echo 'The log is attached'; uuencode `date +\%A`.txt) | 
mail -s 'The daily chat log' [email protected] 

This works well for me with Gmail. But the customer is only using Mail.ru or Yandex.ru accounts and there it looks bad - no attachment is shown and he sees the uuencode output inline (aka begin 664 MT)Blah§$%&Blah):

Yandex mail screenshot

My question is if there is a safer way to send a cron job output by mail as a text file attachment. I know that a lot can be done with the help of perl (and I can program it), but I wonder if there is an easier way - with uuencode or mailx or some other utility?

1 Answer 1

2

mailx has the -a <filename> switch to add attachments. And on CentOS 6 by default /bin/mail is already mailx.

2
  • +1 thanks. I've noticed that too, but I have a STDOUT from grep here and not a file. Should I redirect it to a temp file or is there maybe some nice trick (like using - as a pseudo filename)? Sep 25, 2014 at 11:37
  • Indeed convert the cron entry to call a simple shell script that creates the temporary file, sends a mail message with the report as attachment and then removes the temp file. Posting here takes longer than writing the script. Possibly since you have a temp file include some stats in message body as well,
    – HBruijn
    Sep 25, 2014 at 11:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .