LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-22-2009, 01:16 PM   #1
chris24300
Member
 
Registered: Jul 2009
Posts: 58

Rep: Reputation: 15
Can someone explain cron in some detail?


Hi,

I'm completing a homework assignment on cron. I've used cron and crontabs before to schedule a weekly virus check with clam. There are two tasks that are ambiguous to me. Can someone please explain them?

1. list all system files used by cron. - I've been through all the cron folders in /etc/ (cron.d, cron.daily, cron.hourly, cron.monthly, cron.weekly). cron.daily is the only folder with multiple scripts such as 0anacron, cups, logrotate, mlocate.cron, prelink, and so on. Are these the system files the task is asking for?

2. Identify the daemons associated with cron and running on the system. It says to capture the info on the daemons using ps command. - Where I'm confused is that there is no crontab for root. /var/spool/cron is empty so I feel like cron isn't running nor are there any daemons associated with it.

Thanks,
Chris
 
Old 10-22-2009, 01:50 PM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,549
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

Quote:
Originally Posted by chris24300 View Post
Hi,

I'm completing a homework assignment on cron. I've used cron and crontabs before to schedule a weekly virus check with clam. There are two tasks that are ambiguous to me. Can someone please explain them?

1. list all system files used by cron. - I've been through all the cron folders in /etc/ (cron.d, cron.daily, cron.hourly, cron.monthly, cron.weekly). cron.daily is the only folder with multiple scripts such as 0anacron, cups, logrotate, mlocate.cron, prelink, and so on. Are these the system files the task is asking for?

2. Identify the daemons associated with cron and running on the system. It says to capture the info on the daemons using ps command. - Where I'm confused is that there is no crontab for root. /var/spool/cron is empty so I feel like cron isn't running nor are there any daemons associated with it.

Thanks,
Chris
As the 'man cron' states that the deamon executes scheduled commands;

Quote:
excerpt from 'man cron';

cron - daemon to execute scheduled commands (ISC Cron V4.1)

SYNOPSIS
cron [-l load_avg] [-n]
DESCRIPTION
Cron should be started from /etc/rc or /etc/rc.local. It will return immediately, so you don't need to start it with '&'. The -n option changes this default behavior causing it to run in the foreground. This can be useful when starting it out of init.

Cron searches /var/spool/cron for crontab files which are named after accounts in /etc/passwd; crontabs found are loaded into memory. Cron also searches for /etc/crontab and the files in the /etc/cron.d directory, which are in a different format (see crontab(5)). Cron then wakes up every minute, examining all stored crontabs, checking each command to see if it should be run in the current minute. When executing commands, any output is mailed to the owner of the crontab (or to the user named in the MAILTO environment variable in the crontab, if such exists).

Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified. Note that the Crontab(1) command updates the modtime of the spool directory whenever it changes a crontab.
By looking at the '/var/spool/cron/crontabs/root' you can get some good examples.

Quote:
'/var/spool/cron/crontabs/root';

If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null. We'll do this here since these jobs should run
# properly on a newly installed system, but if they don't the average newbie
# might get quite perplexed about getting strange mail every 5 minutes. :^)
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this. If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null
Your ''/etc/'; cron.d, cron.daily, cron.hourly, cron.monthly, cron.weekly files within the directory are used to simplify your placement of scripts to be performed at the scheduled time. As I said 'script' is used to do your placement of the desired commands within the cron.schedule job desired. You will have cleaner operations by calling a script within the cron.schedule job.

I would suggest that you approach your instructor with your question(s). That way he/she can aid in the area of concern.
 
Old 10-22-2009, 02:54 PM   #3
chris24300
Member
 
Registered: Jul 2009
Posts: 58

Original Poster
Rep: Reputation: 15
I just answered my own questions... thanks for your response.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Explain about Cron,Crontab and Cronjob radhikasambu Linux - Newbie 3 06-21-2009 09:30 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
where can find file "/etc/init.d/functions " detail explain cnhawk386 Linux - Software 3 09-20-2007 11:44 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 02:50 PM


All times are GMT -5. The time now is 06:33 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration