0

I am banging my head against the wall here trying to figure this out. I have an automated DNS propagation system I am trying to build internally, and everything works except rndc flushname. If I do this at a shell prompt

$ sudo rndc flushname /var/lib/bind/$domain.hosts
$ sudo rndc reload

This works

Also if I create the following bash script:

#!/bin/bash
domain="some-domain.com"
# Do stuff 
rndc flushname /var/lib/bind/$domain.hosts
rndc reload

And run it

$ sudo bash myScript.sh

It works.

This command is not working if I assign the script to a cron job though IE

$ sudo crontab -e

.... ....

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

Why does rndc work from straight shell. It also works manually called in a bash script. But when called from crontab it doesn't reload? All commands are run through sudo and the crontab is also running under root. I am not sure what the issue is here? Is there another method to call rndc flushname ?

Zak
  • 153
  • 9
  • You can redirect the output of your cron command to a file, and check it for errors. My guess would be that rndc is in /usr/sbin, and that is not in cron's (very minimal) PATH – steeldriver May 30 '23 at 21:24
  • OK I have changed it to full path --> /usr/sbin/rndc flushname /var/lib/bind/$domain.hosts -- Also keeping an eye on /var/mail/root as all my cron jobs output there. I will report back after cron runs this next time .. – Zak May 30 '23 at 21:29
  • I feel stupid. I should have known better! Post this an an answer and I'll accept unless you can find this as a duplicated OP .. But I did search it out, I promise! – Zak May 30 '23 at 21:33

0 Answers0