non-interactively update FreeBSD system ?

Hey,

I have script called chmody. It is in /usr/sbin/chmody:
Code:
echo "Update Host" >> /root/log
freebsd-update fetch install >> /root/log

echo "Update jail Oksymoron" >> /root/log
freebsd-update -b /zroot/Oksymoron fetch install >> /root/log
I've added to /etc/crontab
Code:
# $FreeBSD: release/10.0.0/etc/crontab 194170 2009-06-14 06:37:19Z brian $
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
#
#minute hour    mday    month   wday    who     command
#
*/30    *       *       *       *       root    /usr/sbin/chmody
When cron(8) starts I get info in /root/log as below:
Code:
cat /root/log
------------------------------------------
Update Host
freebsd-update fetch should not be run non-interactively.
Run freebsd-update cron instead.

------------------------------------------
Update jail Oksymoron
freebsd-update fetch should not be run non-interactively.
Run freebsd-update cron instead.

------------------------------------------
What does he mean? When I put these command in console by hand works like a charm. With cron(8) I get some weird stuff ?
Why?
 
Don't edit /etc/crontab. It's going to be overwritten the next time you try to update. Use crontab -e as root. And you can't run freebsd-update(8) from cron(8) because it requires user interaction (you have to tell it what to do when it asks for something).

I also don't recommend doing this automatically. It's bound to screw up your system at some point. And updates are quite uncommon so it's rather pointless doing this every half hour. Run it when there's a security advisory only.
 
There is some code in the freebsd-update script to stop you from shooting yourself in the foot. The point would be to run freebsd-update cron in root user's crontab which will download the updates into /var/db/freebsd-update and email you about the update. That way you can just run the install command and restart services or reboot depending on what the appropriate action is.
 
Back
Top