[Bug 1481579] [NEW] amavisd-new throws stderr when running cron job
quanta
1481579 at bugs.launchpad.net
Wed Aug 5 04:58:16 UTC 2015
Public bug reported:
- 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
** Description changed:
- 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
+ #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
- ;;
+ 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).
--
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to amavisd-new in Ubuntu.
https://bugs.launchpad.net/bugs/1481579
Title:
amavisd-new throws stderr when running cron job
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/amavisd-new/+bug/1481579/+subscriptions
More information about the Ubuntu-server-bugs
mailing list