SuSE GmbH

SuSE Support Database

Title: System cronjobs do not get executed

----------

Mainpage o Searchform o History o Versions o Categories o Contents
Deutsch

----------

System cronjobs do not get executed

Applies to

SuSE Linux: Version 6.0

Symptom:

In the directories /etc/cron.hourly and /etc/cron.daily there are scripts that do not get executed.

Reason:

The script /usr/lib/cron/run-crons, which starts cron every 15 Min. and in turn calls the system cronjobs, uses the find command to determine time differences. The time of the last execution of the cron job is compared to a time stamp for that cron job, which is stored in the file /var/cron/lastrun. This comparison is requested by the find utility. Unfortunately find has a small bug in ctime.

Workarounds:

Until a new version of find is available, there are two posibilities:

1st Possibility

Change the file /etc/crontab with the following substitutions:
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root

#-* * * * *    root  test -x /usr/sbin/atrun && /usr/sbin/atrun
0 * * * *      root  test -x /usr/sbin/faxqclean && /usr/sbin/faxqclean
5 22 * * *     root  test -x /usr/sbin/texpire && /usr/sbin/texpire
25 23 * * *    root  test -e /usr/sbin/faxcron && sh /usr/sbin/faxcron | mail FaxMaster
45 6 * * *     root  test -x /etc/cron.daily/aaa_base && /etc/cron.daily/aaa_base
50 6 * * *     root  test -x /etc/cron.daily/tetex.cron && /etc/cron.daily/tetex.cron
Make sure that, only root has read and write access to the file /etc/crontab. The rights can be modified with the following commands:
chown root.root /etc/crontab
chmod 600 /etc/crontab

2nd Possibility

The script /usr/lib/cron/run-crons should be substituted with the following script:
#!/bin/bash
#
# /usr/lib/cron/run-crons
#
#
# Copyright (c) 1998 SuSE GmbH Nuernberg, Germany.  All rights reserved.
#
# Author: Burchard Steinbild , 1998
#
# this script looks into /etc/cron.{hourly,daily,weekly,monthly} for
# scripts to be executed.  The info about last run is stored in
# /var/cron/lastrun
#
# concept similar to debian and redhat
#

mkdir -p /var/cron/lastrun

for CRONDIR in /etc/cron.{hourly,daily,weekly,monthly} ; do
    test -d $CRONDIR || continue
    BASE=${CRONDIR##*/}
    test -e /var/cron/lastrun/$BASE && {
        case $BASE in
          cron.hourly)  TIME="-cmin  +60 -or -cmin  60" ;;
          cron.daily)   TIME="-ctime +1  -or -ctime 1"  ;;
          cron.weekly)  TIME="-ctime +7  -or -ctime 7"  ;;
          cron.monthly) TIME="-ctime +30 -or -ctime 30" ;;
        esac
        eval find /var/cron/lastrun/$BASE $TIME | \
             xargs --no-run-if-empty rm
    }
    if test ! -e /var/cron/lastrun/$BASE ; then
        touch /var/cron/lastrun/$BASE

        # keep going when something fails
        set +e
        for SCRIPT in $CRONDIR/* ; do
            test -d $SCRIPT && continue
            if test -x $SCRIPT ; then
                $SCRIPT
            fi
        done
    fi
done

#
# now make sure, we have no lastrun files dated to future
#
touch /var/cron/lastrun
find /var/cron/lastrun -newer /var/cron/lastrun | \
             xargs --no-run-if-empty rm

----------

See also:

----------

Keywords: CRON, CRONTAB, AAA_BASE, TETEX.CRON, CRON.DAILY, UPDATE, LOCATE, 6.0

----------

Categories: Administration

----------

Mainpage o Searchform o History o Versions o Categories o Contents
Deutsch

----------

SDB-wey_cron, Copyright SuSE GmbH, Nuremberg, Germany - Version: 20. Dec 1998
SuSE GmbH - Last generated: 07. Oct 1999 18:21:25 by maddin with sdb_gen 1.00.0