2009-10-21 11:26

I looked for a way of changing mail format sent by the crontab.
I hoped for a syntax like MAILTO=

Answer: Impossible.

With Debian default cron program, it’s hard coded in cron :

In do_command.c source file:

fprintf(mail, "From: root (Cron Daemon)\n");
fprintf(mail, "To: %s\n", mailto);
fprintf(mail, "Subject: Cron <%s@%s> %s\n",
  usernm, first_word(hostname, "."),
  e->cmd);
2009-10-21 11:26 · Tags: , , ,

3 Comments

  1. Tu peux par exemple modifier l’emeteur du mail avec postfix. Il doit aussi y avoir moyen de passer le mail dans une moulinette.

    Bon clairement, c’est sale je te l’accorde. :-)

    Reply

  2. Tu as raison c’est sale..
    à ce compte là plutôt envoyer un mail à la mimine depuis le script ;)

    Reply

  3. Solution: crontab -e

    add
    2>&1 | mailx -s “your subject here” your_email@somewhere.com
    to cron command

    example:
    * * * * * /some/dir/script_to_run 2>&1 | mailx -s “your subject here” your_email@somewhere.com

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *