Logwatch mdadm script not working in cronjob

I have an openSUSE Leap 15.6 soft RAID10 configured. When I run sudo logwatch --detail high --range yesterday --service mdadm I get the following output:

 --------------------- Mdadm Begin ------------------------

 /dev/md/system_raid10 : active
          Raid Level : raid10
        Good Devices : /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1


 ---------------------- Mdadm End -------------------------

But when it’s run as a cronjob this is the output:

--------------------- Mdadm Begin ------------------------ 

 /dev/md/system_raid10 : 
 	  Raid Level : 
 	      Spares : 
 
 
 ---------------------- Mdadm End ------------------------- 

I also have PrivateDevices set to false:

systemctl show logwatch -p PrivateDevices
PrivateDevices=no

Any idea what the issue is?

Please show! Whose crontab? What is the crontab entry:

crontab -l

We can not even try to find any errors or mistypings in what you do when you do not show it.

Because it’s pretty straightforward:

sudo crontab -l
@daily /usr/sbin/logwatch --detail High --range Yesterday --mailto d****r@gmail.com &> /dev/null

This is not a very effective remark because

  • we can not know until we see it;
  • when it is so straightforward, then why do you have a problem.

I never use sudo , but are you sure that this is executed in the environment of the effective user and not using that of the invoking user? I don’t, this could very well be the crontab of the user you keep secret (by not posting the prompts).

when it is so straightforward, then why do you have a problem.

You’ve crystalized my thoughts exactly.

It doesn’t matter whether I use sudo, su -, or login as root, the result is the same. It’s only cron that isn’t working. And as I’ve demonstrated above, running sudo crontab -l shows that the job is defined and presumably running under the root profile. Furthermore, there are no cron jobs defined under the user account.

When you checked that, it is OK and my idea was not correct.

I got another idea from your first post. You say there that cron is working, the job is started. You only indicate that the output of the command that is run in the job is not according to your expectations.

That’s correct. I get all the other logwatch content in the e-mail. It’s only mdadm that’s missing content, and only when run using cron.

That is why I got the idea that it was not “running as root”.

Maybe you can test what the output is when you try as a normal user. Just to compare.

Normal users don’t have permission to run logwatch. It requires root.

The command line in the crontab -l output is different to the command line in your OP.

The OP wasn’t an output of crontab -l.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.