This is best automated by the root/admin account and not left in the files of a standard user.
The best practice concerning what you want to accomplish is to become root sudo su -
and then work in the /root user dir. Something like this is usually best kept in ~/bin
or ~/scripts
so if it doesn't exist you may need to create it and than verify that the new home is part of your PATH
. It is always a good idea to keep a scripts directory of some sort to house the little scripts that you use to manage your system(s) over time you will end up with quite a few and every administrator has his/her "toolbox" that they keep for these things. The trick is to try to write code that is reusable and thereby make your life easier.
If you are going to utilize a number of these files I would create a special dir for them like ~/scripts/sysupdates
and try to keep each file to doing only one thing. This mirrors the function of other *nix systems like init.d and will make maintaining the system easier and intuitive. This also has the purpose of limiting our entries in other places, as you will soon see.
if you create the files for what you want to update as mentioned above (eg. postfix, qmail, update) then you can loop through them with one script in ~/scripts which can be something like:
#/usr/bin/bash
#
# Script: updater.sh
# Author: My Name
# Date: yyyymmdd - ee (ee = times edited)
#
# Purpose: run update scripts from ~/scripts/sysupdates
#
# Notes:
#
for SCRIPT in `ls ~/scripts/sysupdates`; do ${SCRIPT}; done
Do yourself a favor and get in the habit of making proper header for each file you create. It only takes a minute and will save headaches down the road, remember you may not remember why you created it later or what it did, or it may not be you who has to maintain it one day.
The last part of this to edit the root crontab. Cron is a program that runs a given script at a specified interval. So if we add our updater.sh script to the crontab all we have to do is add files to ~/scripts/sysupdates
and they will get run automatically.
You access the crontab with crontab -e
which will edit the crontab with the defined system editor (usually vim in linux).There is a crontab generator to help you at:
http://www.thepcmanwebsite.com/crontab_generator.shtml for making your own.
Add the line:
5 0 1 * * /root/scripts/updater.sh
You should be good to go.
Have fun with these tools as they can make life of a SysAdmin much easier.
One word of caution; I would not add apt-get -y dist-upgrade to your scripts, run that one when you are prepared to deal with it, should it run awry.