LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 09-30-2009, 06:03 PM   #1
glore2002
Member
 
Registered: Mar 2007
Location: Buenos Aires, Argentina.
Distribution: Debian Lenny AMD64
Posts: 506

Rep: Reputation: 32
cron.hourly cron.weekly cron.monthly and 0anacron. Are they necessary?


Hello!

I set some jobs via crontab -e. For instance, I use it to run my tv recorder script an also to turn off computer at night.

Inside /etc, I found different types of cron directories (cron.hourly; cron.weekly and cron.monthly). Cron.hourly is empty but the rest contain a file called 0anacron and if I open it, it looks like this (the only thing changing is that instead of cron.daily, the script uses cron.weekly or cron.monthly depending if the are inside cron.daily; cron.weekly or cron.monthly):

Quote:
#!/bin/sh
#
# anacron's cron script
#
# This script updates anacron time stamps. It is called through run-parts
# either by anacron itself or by cron.
#
# The script is called "0anacron" to assure that it will be executed
# _before_ all other scripts.

test -x /usr/sbin/anacron || exit 0
anacron -u cron.daily
Are these scripts necessary to use cron? What happens if I comment those two lines inside the script? Will anything change? What do they do?

I will really appreciate your replies and explanation.

Thank you!

Last edited by glore2002; 09-30-2009 at 06:06 PM.
 
Old 09-30-2009, 07:15 PM   #2
americancaesar
LQ Newbie
 
Registered: Jan 2008
Location: Oregon
Distribution: debian, CEntOS, parted magic
Posts: 3
Blog Entries: 2

Rep: Reputation: 0
yes

cron.daily, etc...

these directories should be referenced from your /etc/crontab file. they are meant to save you the trouble of editing the /etc/crontab file directly. you can tweak when all daily, weekly, monthly jobs run in cron by just changing the schedule for the line referencing them in /etc/crontab. that way you can just place a script or a symlink to a script in the directory and it will run on the given interval. scripts should be run in order by using a lexical sort of the script names.

so, if you are shutting your computer down using a cron script... you want to make sure it is run last. you may want to keep it in the crontab or if in cron.daily make sure that it is listed last in the directory when sorted by name and that the cron.daily is the last of the cron groups to run to prevent having missed jobs that need to be picked up.

enter anacron ...

anacron is kind of a safeguard since cron basically assumes that your computer is always on. when you invoke anacron it checks timestamps to make sure your cron jobs have run within the desired time interval. usually anacron is invoked at least at boot time. if your anacron timestamps are out of the accepted time limit, if you missed your daily jobs, the cron jobs are processed with a 5-ish minute delay after your computer boots up. the 0anacron file you have is doing two things... 1. testing to see if anacron exists; and, 2. updating the timestamps.
 
Old 09-30-2009, 08:57 PM   #3
glore2002
Member
 
Registered: Mar 2007
Location: Buenos Aires, Argentina.
Distribution: Debian Lenny AMD64
Posts: 506

Original Poster
Rep: Reputation: 32
Thanks americancaesar for such an explanation!
Very clear.

Thanks again,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 06:37 PM
cron.daily, cron.weekly not working mwhite74 Linux - Server 2 06-07-2007 09:51 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 01:50 PM


All times are GMT -5. The time now is 11:23 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration