1

Is there a way to limit the body of all e-mails sent out by cron (to MAILTO receivers) to a specific length. If the particular output exceeds the limit, it just gets cutt off at that point.

Is there a way to do it globally, not by cutting off the output of each cron-job individually?

1 Answer 1

2

Cron does not provide such a feature, at least not that I know of. You can address it in two ways:

  1. limit the output of what you're running in cron (maybe by piping in some other unix tool)
  2. limit the size of emails in your MTA (eg. in postfix it would be the message_size_limit parameter)
4
  • 1
    I agree with number one. I don't agree with number two which means you'd probably throw away the whole email, which is not good.
    – chutz
    Dec 11, 2012 at 23:59
  • Thank you for the answer! So, there is no way to set it for all cron jobs globally, I have to cut off the output of each job separately (e.g. by piping in some other unix tool). Number two won't do for me, as that was exactly the problem - to receive at least some e-mail if the original report is too large to fit into one wholly. Dec 12, 2012 at 10:35
  • @chutz, I answered the original question, but I don't agree with either solution. If you "cut" (in whole or in part) the mail you are not interested in, and the right thing to do is not generate unneeded output in the first place. The script/binary he is running in cron is broken and needs to be fixed (remove unnecessary output).
    – Luke404
    Dec 12, 2012 at 14:24
  • 1
    @Luke404: What we do at work is that we keep the complete log in a file on the local disk, and we only mail an excerpt (we cut it to 100 lines from top and 200 lines from bottom) of the mail. You get a clue of what's wrong in the email, and you can always go to the machine and see it all. And of course tmpwatch keeps the log directory clean. So I kind of agree with chopping the mails, but I also agree that you should still keep the complete logs somewhere. Feel free to update the answer if you found something useful here.
    – chutz
    Dec 12, 2012 at 15:40

You must log in to answer this question.

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