I put a rkhunter script in daily.cron on Apache Centos 7.
When I manually run the script, it works fine. but leaving it in daily.cron it fails to run.
I get this email every day instead.
/etc/cron.daily/rkhunter:
/etc/cron.daily/rkhunter: line 3: rkhunter: command not found
if you look in cron.daily you see a rkhunter script. inside that script this is the contents.
#!/bin/sh
OUTPUT=`rkhunter --update --cronjob --report-warnings-only --nocolors --skip-keypress`
if [ "$OUTPUT" != "" ]
then
echo $OUTPUT | mail -s "[rkhunter] Warnings found for $(hostname)" email@example.com
fi
if i manually run
sh rkhunter
from that directory it works. I tried to have a file extension on it rkhunter.sh but it was the same result so with or without the .sh extension i am not sure it makes a difference.
How can I get this script to run daily and not fail with command not found.
OUTPUT=\rkhunter --update --cronjob --report-warnings-only --nocolors --skip-keypress`` calls program "rkhunter" that is not found. Try changing it to absolute path. – yahol Mar 13 '18 at 13:16/bin:/usr/bin. The vast majority of "my cron script doesn't work" problems are caused by this restrictive path. If your command is in a different location you can solve this in a couple of ways: ... provide the full path to/path/to/rkhunter– HBruijn Mar 13 '18 at 13:34