[Bug 1481579] [NEW] amavisd-new throws stderr when running cron job
Launchpad Bug Tracker
1481579 at bugs.launchpad.net
Thu Aug 6 22:58:14 UTC 2015
You have been subscribed to a public bug by Robie Basak (racb):
- Ubuntu 14.04.2 LTS
- amavisd-new 1:2.7.1-2ubuntu3
/etc/cron.d/amavisd-new
```
#
# SpamAssassin maintenance for amavisd-new
#
# m h dom mon dow user command
18 */3 * * * amavis test -e /usr/sbin/amavisd-new-cronjob && /usr/sbin/amavisd-new-cronjob sa-sync
24 1 * * * amavis test -e /usr/sbin/amavisd-new-cronjob && /usr/sbin/amavisd-new-cronjob sa-clean
```
The contents of `/usr/sbin/amavisd-new-cronjob` file:
```
if ! perl -MMail::SpamAssassin -e "my \$spamtest = Mail::SpamAssassin->new();
\$spamtest->compile_now (); \$spamtest->{conf}->{use_bayes} ? exit 0 : exit 1"
then
#bayes is disabled - just exit
exit
fi
case $1 in
sa-sync)
/usr/bin/sa-learn --sync 2>&1 >/dev/null
;;
sa-clean)
/usr/bin/sa-learn --sync --force-expire 2>&1 >/dev/null
;;
*)
echo "$0: unknown cron routine $1" >&2
exit 1
;;
esac
```
There are 2 problems here:
1. It throws a stderr message at the first time running:
```
bash -x /usr/sbin/amavisd-new-cronjob sa-sync
+ test -e /usr/bin/sa-learn
+ test -e /usr/sbin/amavisd-new
++ id --name -u
+ '[' amavis '!=' amavis ']'
+ set -e
+ umask 022
+ perl -MMail::SpamAssassin -e 'my $spamtest = Mail::SpamAssassin->new();
$spamtest->compile_now (); $spamtest->{conf}->{use_bayes} ? exit 0 : exit 1'
config: created user preferences file: /var/lib/amavis/.spamassassin/user_prefs
+ case $1 in
+ /usr/bin/sa-learn --sync
+ exit 0
```
This should be silent as it's run in a cron job.
2. To redirect both stdout and stderr to /dev/null, the redirection
order should `>/dev/null 2>&1` instead of `2>&1 >/dev/null` (this one
just redirects stdout).
** Affects: amavisd-new (Ubuntu)
Importance: Undecided
Status: New
--
amavisd-new throws stderr when running cron job
https://bugs.launchpad.net/bugs/1481579
You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to the bug report.
More information about the Ubuntu-server-bugs
mailing list