1) depending on your distro you might already have cronwrap intsalled or in the repo(s)
if not download and install
tar xvfz cronwrap*.tar.gz
python setup.py install
exit ; cd
2) /etc/anacrontab is the main config file as well as /etc/crontab for "root" jobs in the system.
this exercise does not deal with these files, but they can be modified for added root tasks for the system for regular tasks.
3) create/start your own crontab under your username located in /var/spool/cron. the simple task of resetting the kernel and pulling.
enter the entries for the times you want etc.. then save and exit.
30 21 * * * /usr/bin/cronwrap -c "/home/kernel./pull_script" -e firstname.lastname@example.org -v
NOTE: below is my simple script I used for this example
# my cheesy script to pull the kernel
for dir in /home/kernel/3.0*
cd /home/kernel/3.0 ; git reset --hard origin ;
git checkout master ; git pull ;
git checkout Mattock ; git reset --hard origin ; make
I used cronwrap since it makes sending info to myself much easier, and supplies good info in the email on how everything went(not just when things crap out)
crond does send emails but only if the scripts fails. to add this option add:
MAILTO= yourname@.com at the top of your crontab -e
4) create another task as "root" to complete the job
add the root commands that need to fire off after the pull and build go through.
30 22 * * * /usr/bin/cronwrap -c "cd /home/kernel/3.0 ; make modules_install ; make install" -e email@example.com -v
probably should of created another script, but wanted to show you don't need to make scripts to do this..
5) check the logs,(/var/log/cron) and wait for the email.. hopefully everything goes good for whatever commands you use!
the first script for pulling went good, but then when it came for the root crontab I hit a strange error:
/sbin/installkernel: line 82: new-kernel-pkg: command not found
/sbin/installkernel: line 86: new-kernel-pkg: command not found
make: *** [install] Error 127
make: *** [install] Error 2
quick fix is to edit this file at 82 and 86 by adding the full path to the programs
and there you have it.. a simple cron example of pulling and resetting the kernel, then building and installing everyday between 8-9:30pm without having to do anything..because we all know how hard entering commands in a terminal can be!