Search code examples
croncentos7aide

How to add a cron job with crontab -e


My system is centos 7.4.
After crontab -e,I add

MAILTO=root
30 4 * * * root /usr/sbin/aide --check

Then I receive email as below:

From: "(Cron Daemon)" <[email protected]>
To: [email protected]
Subject: Cron <root@myserver> root /usr/sbin/aide --check
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=37>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/0>
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <[email protected]>
Date: Fri,  1 Mar 2019 04:32:01

/bin/sh: root: command not found

I checked /var/log/aide/aide.log is empty, there's no any information in messages and secure.It seemed my crontab script is somewhere wrong.
I just want to receive aide --check report,where is the problem?


Solution

  • The command you must exec is this:

    MAILTO=root
    30 4 * * * /usr/sbin/aide --check
    

    Cron interpret root as command. The original cron records differ from those in cron.daily and so on directories because the standard cron records are per user, not per specific time