I have a cronjob that runs apt-get automatically for Ubuntu 12.04 LTS x64 bit, which all lives as a guest in VirtualBox.
The cronjob is ran as root, however the script that it calls is under a regular users' home directory.
I am able to execute the script from CLI and it updates a log ok. However I'm not sure where the error lies with the cronjob not kicking it off automatically. I have checked /var/log/apt and don't find any entries and I also monitor top to see if the apt process kicks off, and adjust the cronjob's time and watch top and still nothing.
Here is some more info
cronjob
Code:
root@ubuntu64vm:~# crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
00 21 * * * root ./home/cmmiller1973/scripts/aptupdate
Permissions of the script
Code:
root@ubuntu64vm:/home/cmmiller1973/scripts# ls -al
total 12
drwxrwxr-x 2 cmmiller1973 cmmiller1973 4096 Sep 15 08:29 .
drwxr-xr-x 32 cmmiller1973 cmmiller1973 4096 Sep 15 21:31 ..
-rwxrw-r-- 1 cmmiller1973 cmmiller1973 114 Sep 15 08:29 aptupdate
Script
Code:
root@ubuntu64vm:/home/cmmiller1973/scripts# cat aptupdate
#!/bin/bash
(apt-get update && apt-get -y -d upgrade) > /var/log/aptupdate.log
apt-get clean
>/dev/null 2>&1