Activate to launch comment card

anacron for non-root

Normally anacron is launched by root to excecute system-wide task, e.g. backup2l

Non-root users have access to cron but normally can not execute anacron, which seems somewhat unreasonable. Suppose you want to allow user shalaev to run his personal anacron tasks. Type the following under root account:

groupadd anacron
adduser shalaev anacron
mkdir /var/spool/shalaev-anacron
chgrp anacron /var/spool/shalaev-anacron
chmod g+rwx /var/spool/shalaev-anacron 

Next, log in as shalaev and copy the following into ~/anacrontab file

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# period  delay  job-identifier  command
    1       5       shalaev.anacron.daily nice run-parts --report $HOME/anacron.daily

Create directory ~/anacron.daily and populate it with files which you want to excecute daily. Do not forget to chmod +x and remember that program names in ~/anacron.daily must match certain (default) pattern to be excecuted by run-parts, see its man page. (For example, ~/anacron.daily/emacs.sh and ~/anacron.daily/emacs~ will not be launched, but ~/anacron.daily/emacs will.)

Finally we remember that (unlike cron) anacron is not a daemon so it has to be launched manually. You may launch it from your ~/.profile, for example. I run it using the following string in my crontab

11 * * * * /usr/sbin/anacron -S /var/spool/shalaev-anacron -t $HOME/anacrontab

which lauches anacron hourly. Of course, programs in ~/anacron.daily we run only once a day.

validate this page