I'm having trouble with setting a cron job to run daily when I enter the script to /etc/cron.daily
when I put it there it doesn't run at all like it should be doing.
I setup a script so that it can keep my repository up-to-date and then download any new packages it finds that needs upgraded. I didn't want to do crontab -e
because it doesn't let me set its own individual file to run this script because it only seems to dump it into /tmp
directory. Here's what my cron script looks like;
#!/bin/sh
30 22 * * 0 apt-get update && apt-get upgrade -y
There doesn't appear to be any indication that this works, except for the fact I get errors relating to apt in mailx
saying
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root
I would of thought this ran at root level inside of /etc/cron.daily
since it's owned by root? The permissions read as drwxr-xr-x 2 root root 4096 Sep 28 06:02 cron.daily
I wasn't too sure if I should add sudo
to the command because then it would just sit there waiting for a password to be entered.
also how would I be able to get it to log what packages updated so I can review them later? or does apt already log these to it's own log file somewhere? if so where is it? I would like it to just output the name and versions of the packages installed it upgraded from to display something like this into a log file, ie;
<package> @ <version> --> <new_package> @ <version> <date> <time>