Cron jobs under user not running.

Latest response

I am trying to troubleshoot an issue with cronjobs running on a Rhel system.
the seem to have stopped.
The os is Rhel 7.7

I have checked the crond service is running,
The cron jobs exist under /var/spool/cron/userb
there is also a /var/spool/cron/root however this does not contain the crond jobs that are not running

when you run the command crontab -l you get the output as follows

0 5 * * * /usr/sbin/aide --check

I can see reference to this running in the cron logs

however if you run crontab -u userb -l
the cronjobs in question are present however they are not being executed.
i have checked the /var/log/cron and /var/log/message and see no associated logs.

I have also amended the cronjob to output the results to a log directory and that directory remains empty.

Im a little perplexed at this point, what should i do from here?

Responses

Hello Barry,

The "aide" is a 'sbin' command and which can't be run by a normal user without sudo privileges. So, you could enable sudo access on the user "userb" without password prompt and after which the cron job should work.

Something like this would work:

[root@test ~]# crontab -u redhat -l
*/2     *       *       *       *       /usr/bin/sudo /usr/sbin/aide --check &> /tmp/redhat-aide.out

[root@test ~]# cat /var/spool/cron/redhat
*/2     *       *       *       *       /usr/bin/sudo /usr/sbin/aide --check &> /tmp/redhat-aide.out

[root@test ~]# grep redhat /etc/sudoers
redhat  ALL=(ALL)       NOPASSWD:/usr/sbin/aide

This works as expected and every 2 minutes, it triggers the cron job and runs the aide command:

[root@test ~]# grep aide /var/log/cron|tail -1
Jul 27 09:10:02 test CROND[11860]: (redhat) CMD (/usr/bin/sudo /usr/sbin/aide --check &> /tmp/redhat-aide.out)

I hope this helps.