'RHEL 7.9 Cronjob and logger output

I need to be able to run:

clamscan -V 2>&1 | logger

as a cronjob. The output from that is:

ClamAV 0.103.3/26132/Tue Apr  6 04:06:05 2021

I have the cronjob set currently as:

02 * * * * root clamscan -V 2>&1 | logger

I get no results when searching the var/log/messages. Rsyslog is configured to send to var/log/messages. I could also run:

/usr/local/clamav-0.103.3/bin/clamscan -V

That provides the output I need. However, I need to get that output sent to var/log/messages. I do have this set up in crontab:

10 * * * * root /usr/local/clamav-0.103.3/bin/clamscan -V /var/log/messages

and the message I get in var/log/messages is:

CROND[24826]: (root) CMD (root /usr/local/clamav-0.103.3/bin/clamscan -V /var/log/messages)

But I need the output of that, which is:

ClamAV 0.103.3/26132/Tue Apr  6 04:06:05 2021


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source