Mar
11
2007

crontab Configuration, openSUSE 10.2

At some point several years ago, SUSE and Redhat migrated to new multi-file and sub-directory approaches (search anacron) for their system crontabs. A helpful comment posted to my 2 March entry motivated me to learn how these are set up. Here’s how openSUSE 10.2 structures its cron configuration and provides the means of controlling it:

  • YaST, System, sysconfig editor, cron – edits various configuration parameters stored in the /etc/sysconfig/cron file (this file can also be edited directly).
  • YaST, System, System Services – turn the cron service on/off here.
  • /etc/crontab, /etc/cron.d/*, /var/spool/cron/tab/<userid> – these files all use the format described in the crontab 5 man page. My as-installed configuration has one line in /etc/crontab that calls run-crons every 15 minutes (*/15). All of the other directories were empty. Also, the one line starts with a dash, a special feature for root that prevents sending a message to the syslog file.
  • /usr/lib/cron/run-crons – shell script called by the default /etc/crontab entry. run-crons runs all pending shell scripts in the /etc/cron.* sub-directories. This is an extensive script containing the logic to handle systems that don’t run 24×7.
  • /etc/cron.{hourly, daily, weekly, monthly} – these directories contain bash scripts, not crontab-format files.

As installed, /etc/crontab runs dailies within the first 15 minutes after rebooting and every 24 hours thereafter. If one has the misfortune to get that first run during work hours, cron will continue to run the dailies every day at that time! The daily tasks have a lot of system-wide finds (core files, locate, beagle, etc) that consume 100% of the cpu. This annoyed me frequently in my SUSE 10.0 days.

From reading the run-crons code, I found out about the DAILY_TIME parameter in /etc/sysconfig. If this is set, cron runs the daily tasks only during the hour specified. The trade-off is that the computer must be running at DAILY_TIME (but if not, cron will run daily tasks anyway after MAX_NOT_RUN days). The weekly and monthly tasks aren’t controlled by DAILY_TIME, so I guess if I reboot one minute after noon, weekly and monthly tasks will run at 12:15 pm thereafter.

To try all this out, I set DAILY_TIME to 14:00 and changed the /etc/crontab minutes parameter to 22,52, and will expect to see activity each day at 2:22 pm.

A nice extension would be a WORK_DAY parameter; a time span during which cron would avoid running any of the periodic tasks. This would retain cron‘s ability to run tasks within the first 15 minutes after a reboot, so long as it didn’t occur during work hours.

posted in SUSE, SysAdmin, YaST by Bozzie

1 Comment to "crontab Configuration, openSUSE 10.2"

  1. dj wrote:

    > YaST, System, System Services – turn the cron service on/off here.
    How does all this work under YaSt2 which does not have System, System Services or anything similar to these options?

    Thank you

    dj

 
Powered by Wordpress and MySQL. Theme by openark.org