Q:

setting up anacron for version control update

I store some of my configuration files in version control. Recently I tried to setup a daily anacron job so that I won't have to manually update the files. I have never used cron or anacron before but reading through cron documentation I decided to put my script in /etc/cron.daily. Below is my script named dot-files (changed to executable with chmod +x):
#!/bin/sh

cd /home/dell/dot-files && /usr/bin/git add . && /usr/bin/git commit -a -m 'daily update' && /usr/bin/git push -u origin master

However it doesn't seem to be running for the last two days. Here are the lines from /var/log/syslog:
Aug 21 10:42:02 dell-Studio-1535 anacron[1023]: Job `cron.daily' terminated (exit status: 1) (mailing output)
Aug 21 10:42:02 dell-Studio-1535 anacron[1023]: Can't find sendmail at /usr/sbin/sendmail, not mailing output

Can anyone see what's wrong with that? Also am I using a wrong setup for the purpose?
p.s. I'm using an ubuntu 12.04 system and it's not always running.

A:

OK, first things first. You don't see what went wrong because cron could not mail you the output. Instead, however, of configuring your sendmail, modify your script such that it stores the output of your commands:
#!/bin/sh

export workdir=/home/dell
export logfile=$workdir/dot-files.log
export errfile=$workdir/dot-files.err
date >> $logfile
date >> $errfile

{ cd $workdir/dot-files && /usr/bin/git add . && /usr/bin/git commit -a -m 'daily update' && /usr/bin/git push -u origin master ; } >> $logfile 2>> $errfile

Furthermore, you do not need to put it into the cron directly as root, you can run crontab as user.
man crontab

P.S. What happens when you run that script manually?

