Confused about relationship between cron and anacron - Ask Ubuntu


i've been googling in vain turn general explanation of how cron , anacron work together. man pages bit deep of dive me @ point.

i confused because add tasks crontab, , works, when delete them out of crontab, still run under anacron. see tasks in /etc/cron.daily, not sure how got there. cron running on system always, not anacron. in fact, see anacron started cron!

basically i'd user-level intro on how add , remove tasks, since googleable answers tell edit crontab not complete. link tutorial fine.

both cron , anacron daemons can schedule execution of recurring tasks point in time defined user.

the main difference between cron , anacron former assumes system running continuously. if system off , have job scheduled during time, job never gets executed.

on other hand anacron 'anachronistic' , designed systems not running 24x7. work anacron uses time-stamped files find out when last time commands executed. maintains file /etc/anacrontab cron does. in addition, cron.daily runs anacron everyhour. also, anacron can run job once day, cron can run every minute.

from man anacrontab:

when executed, anacron reads list of jobs configuration file, /etc/anacrontab (see anacrontab(5)). file contains list of jobs anacron controls. each job entry specifies period in days, delay in minutes, unique job identifier, , shell command.

for each job, anacron checks whether job has been executed in last n days, n period specified job. if not, anacron runs job's shell command, after waiting number of minutes specified delay parameter.

after command exits, anacron records date in special timestamp file job, can know when execute again. date used time calculations. hour not used.

this means, if task scheduled run daily , computer turned off during time, when anacron run, can see task last run more 24 hours ago , execute task correctly.

for example if specify following in /etc/anacrontab:

7       15      test.daily      /bin/sh /home/username/script.sh 

and on day when script.sh job supposed executed, if system not running, anacron execute script.sh 15 minutes after system comes up.

few reference:

anacron sourceforge page

digital ocean page

redhat documentation on cron , anacron


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User