0

I have a file:

/etc/bind/dnsCron/dnsCron.sh

I run it via cron every 5 minutes:

*/5 * * * * sh /etc/bind/dnsCron/dnsCron.sh

Inside dnsCron.sh I have a line that succeeds when I run it command line .. But it fails in the cron -- Error log:

/etc/bind/dnsCron/dnsCron.sh: 124: /etc/bind/dnsCron/dnsCron.sh: named-checkconf: not found

The line(s) in question: dnsCron.sh

    >/etc/bind/dnsCron/checkconf
    named-checkconf -z > /etc/bind/dnsCron/checkconf

Is there anything wrong with running a subshell in an shell script called by crontab? I have a feeling it doesn't like me calling named-checkconf directly. What's the correct way to get named-checkconf -z results into the file checkconf when run through crontab?

Zak
  • 354
  • 4
  • 17
  • 1
    Fix your path. The error is telling you it can't find the command, and that's because it's not in the PATH the shell is using. –  May 03 '17 at 21:07
  • Do you know the path to named-checkconf? – Zak May 03 '17 at 21:08
  • 1
    On your server? No, no clue. –  May 03 '17 at 21:09
  • On Ubuntu 16.04 it's located in `usr/sbin/named-checkconf` --- If you'd quickly write an answer explaining why the shell run as `root` can see the PATH but cron doesn't. Does cron not use the same PATH even if cron was run as the same user? Your suggestion fixed it, I just would like clarification as to "why". – Zak May 03 '17 at 21:17

0 Answers0