I wanted to use the cron system to update an Ubuntu machine everyday and send me emails with the results.
In order for the Ubuntu machine to send email from the cron job it needs to have the email in the command line set up see this post
We decided to write a shell script to do the job and then have it called by the cron job. This is an example of the script ( the -y option answers yes to questions that would be asked) You must make sure that the script is excecutable ie type “chmod 755 script.sh”
#!/bin/bash proxy=http://proxy.url.com:8080 export http_proxy=$proxy apt-get -y update apt-get -y upgrade updatedb
We are using the crontab that belongs to root (to access this “su” and then “crontab -e”) as the update commands must be performed as root.
Below is an example of our cron job, not you can send the results of the job to more than one person if you seperate each email address with a comma
MAILTOfirstname.lastname@example.org, email@example.com # m h dom mon dow command 01 01 * * * /path/to/shell/script.sh