I have a server monitoring script which, among other things, checks the state of an IPSec tunnel usingipsec auto --statusIt works like a charm when run from the console (as root) but as soon as I run it from a (root) cronjob, the command fails: no output at all.I even tried to create this simple root cronjob:*/1 * * * * ipsec auto --status > /tmp/ipsec.txtAll it does is create an empty /tmp/ipsec.txt file!Note: All other tasks in the script including networking and DB access work fine.Any lights welcome.
ipsec auto --status fails in cronjob
centos;cron;ipsec
It sounds like cron is not seeing ipsec in the path. It's a pretty good habit to include absolute paths to binaries in crontab. There is probably some complaining in /var/log/messages or /var/log/cron.*/1 * * * * /usr/sbin/ipsec auto --statusYou could also add the PATH environment variable to the top of the crontab. The PATH will apply to all the jobs in the crontab.PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:*/1 * * * * /usr/sbin/ipsec auto --status