Automatic update script issue (Ubuntu server)

Hi,

I've created a very basic script to run apt-get update and apt-get dist-upgrade unattended (run with cron) and save the logs. Though, it's not really a script, just a file containing the commands to run in order: pasteit .com/18601

I'm currently testing this and ran into some unexpected behavior during the recent Kernel upgrade: pasteit .com/18602

It appears the grep for the Kernel name kicked in and restarted the server before the upgrade even started. Does apt-get dist-upgrade run in the background or should the script wait for the process to finish before proceeding to the next step?

The following day it then did it correctly but in a non-test scenario it wouldn't run for another month pasteit .com/18603

I'm basically trying to find out if this is a script error. Someone else mentioned that they checked the server the day it failed to update and apt-get dist-upgrade said there were no outstanding patches but I can't confirm this.

Any help would be appreciated!
Raxje

P.S. I realize that the -q is not required, will remove that!

Hello,

Yes, it is recomended that apt-get dist-updagrade finished, the problem just you said, is the grep Kerne. You can try with while or something.

bye.

Thanks for the reply. Unfortunately I didn't fully understand your suggestion.

I'm assuming there's a 'while' command for bash or something? I'll look into it in any case and hope for a reply from yourself - or someone else.

Hello, sorry I try to explain better. Do you need to find some way to check the process apt-get dist-upgrade finshed before check the grep Kernel.

Hi,

I've updated the script a bit: pastie .org/private/ehdhernqizakgqomcznnoa

It no longer reboots when it fails but it's still stopping at:

Get:85 (removed link) precise-updates/main python-crypto amd64 2.4.1-1ubuntu0.1 [293 kB]
Fetched 87.3 MB in 53s (1,632 kB/s)

It doesn't display the echo after dist-upgrade or anything...

As to the previous reply I would like a way to check but I had assumed && was a simple way to achieve this?

Also, I think this might be happening because of errors when trying to fetch files e.g. hash sum mismatches or bad requests..

Please help!