CRON error: grandchild failed with exit status 1 [Solution]

Just after I upgraded my Ubuntu to 10.10 version, I noticed some cron-related error messages in my /var/log/syslog file, like these:

Jul  5 13:40:01 agriope2 CRON[971]: (CRON) error (grandchild #974 failed with exit status 1)
Jul  5 13:50:01 agriope2 CRON[7775]: (CRON) error (grandchild #7778 failed with exit status 1)
Jul  5 14:00:01 agriope2 CRON[14520]: (CRON) error (grandchild #14526 failed with exit status 1)
Jul  5 14:00:01 agriope2 CRON[14521]: (CRON) error (grandchild #14531 failed with exit status 1)

At first, I thought they were generated by one of my scripts, which runs via cron every 10 minutes and I wondered what happened during upgrade that caused its exit status to turn to 1 instead of 0. Unfortunately, I didn’t had the time to delve deeper back then and I ignored it, since everything seemed to work as expected.

Until today, when (after one more successful system upgrade in the meantime) I decided to examine it further.
Given that nothing has changed into my script, I thought that it would be a good idea to search into /etc/cron* directories and there I found that there was the script /etc/cron.d/update-motd, which was scheduled to run every 10 minutes and tried to run /usr/sbin/update-motd. The problem is that /usr/sbin/update-motd was not present any more at its whereabouts, probably because “the functionality formerly provided by update-motd package is now integrated into pam_motd, in libpam-modules” (as the description of update-motd package says).

So, I moved /etc/cron.d/update-motd to another location, just in case I will need it again some time in the future.

Update [2011/12/25]:
In case you are running fetchmail from cron, you ‘ll have messages like the above whenever you have no new mail. For this situation, the solution is already in the man page of fetchmail:

If you do not want “no mail” to be an error condition (for instance, for cron jobs), use a POSIX-compliant shell and add

              || [ $? -eq 1 ]
to  the  end  of  the  fetchmail command line, note that this leaves 0 untouched, maps 1 to 0, and maps all other codes to 1. See also item #C8 in the FAQ.


Visit The Light of the LAMP blog for more…