0

I'm having real problems getting a simple (aide --check) job to run as a crontab job. I've tried everything I can think of but it won't seem to run. I've tried specifying the shell in crontab:

SHELL=/bin/bash

I've tried all kinds of variations of the command line:

*/1 * * * * root /bin/bash /usr/sbin/aide --check
*/1 * * * * /bin/bash /usr/sbin/aide --check
*/1 * * * * root /usr/sbin/aide --check
*/1 * * * * root /bin/bash /usr/sbin/aide --check >> /var/log/SystemFileCheck.log

Plus others but just can't get it to run. I've followed online guides which all say I'm doing it correctly. I've tried putting it into a bash script instead and running that but no luck. What am I doing wrong?

These are some of the errors I'm getting:

Mar 30 11:25:01 localhost CROND[14060]: (root) CMD (root /bin/bash /usr/sbin/aide --check >> /var/log/SystemFileCheck.log) Mar 30 11:25:01 localhost CROND[14058]: (root) CMDOUT (/bin/sh: root: command not found)

Mar 30 11:28:01 localhost CROND[14397]: (root) CMD (root /bin/SystemIntegCheck.sh >> /var/log/SystemFileCheck.log) Mar 30 11:28:01 localhost CROND[14395]: (root) CMDOUT (/bin/bash: root: command not found)

Mar 30 11:39:01 localhost CROND[16094]: (root) CMD (/bin/bash /usr/sbin/aide --check) Mar 30 11:39:01 localhost CROND[16092]: (root) CMDOUT (/usr/sbin/aide: /usr/sbin/aide: cannot execute binary file)

Can anyone shed some light on this?

Thanks in advance

PS. the once a minute is just for testing

Dave748
  • 30
  • 6

1 Answers1

1

A user id can only be specified in the system crontab file. The entries of a user's crontab file don't take a user id. The entries in question are apparently found in a user's crontab file, which is why you get root: command not found from the first, third and fourth entries.

From the second, you get cannot execute binary file because you ask bash to execute /usr/sbin/aide as a bash script when it's not a bash script. You should be using

*/1 * * * * /usr/sbin/aide --check
ikegami
  • 367,544
  • 15
  • 269
  • 518
  • Thanks, I solved the issue with your help. First off I was editing the user crontab when actually I should have been editing the system crontab. I did get the user one to work but when I swapped back to the system one it still does what I need. Thanks so much for your help. Just need to also send the output to a second location now. – Dave748 Mar 30 '20 at 19:00
  • `*/1 * * * * /usr/sbin/aide --check >> /var/log/SystemFileCheck.log` should work just fine. You don't even need to set the `SHELL` var because the command is a perfectly valid command for the default shell (`/bin/sh`) – ikegami Mar 30 '20 at 19:49