I have an Ubuntu machine that I'd like to update automatically. I've written an expect script to run the aptitude package manager and update my packages. Essentially it does:
aptitude update && aptitude upgrade
while answering "yes" at the appropriate time.
It works quite nicely when run directly from the command line. However, when the cronjob I set up runs it (as root), it dies very quickly. In an attempt to figure out what's going wrong, I 'tee'd' the output into a log. In the "aptitude update" stage, it only updates maybe 1/6 of the total sources before inexplicably terminating. It never reaches the "upgrade" stage.
Does anyone have any idea what I might be doing wrong or have any way I might be able to diagnose why the script is quitting early?
I figured the script would still need access to STDOUT given that it acts based upon the output. As I mentioned though, that was only done after the script was found to not work.
That notation is not supported in all flavors of UNIX but Linux is more than happy with it.
Did you try to make a run logging the standard error output to a log file ? if so, what message did you get ?
---------- Post updated at 01:13 AM ---------- Previous update was at 01:11 AM ----------
Also check your environment (in your script before runing the spawn commands, log the output of an "env" command and compare the logged environment (when launched via crontab) with the one you have when you run it manually
Good ideas but neither one helped. This isn't a production box, so it's not that important. I was mostly curious as to whether I was missing something obvious. I could just pipe 'yes' into it to make it work and simplify the process. Thanks for making an effort though!