Raspberry Pi Update fails

Recently I was trying to update Raspbian when my SSH connection failed.  This meant that the update did not complete successfully.  To prevent issues like this in the future I found an app called ‘screen’.  More on this to follow.

The failed update meant that I couldn’t complete any further updates.  When trying to run:

sudo apt-get upgrade

I would get the error:

dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

Running sudo dpkg –configure -a did not correct the problem and caused the SSH connection to time out.  The solution was to flush dpkg with the command below:
cd /var/lib/dpkg/updates
sudo rm *

This removed all ‘bad’ items.  Running the apt-get update and apt-get upgrade commands then worked.