Before writing that script, you might find the cron-apt package does all that you need done once you get it configured correctly.
Before writing that script, you might find the cron-apt package does all that you need done once you get it configured correctly.