Bug 445079

Summary: delay.cron can fail
Product: [Fedora] Fedora Reporter: Dolhay Denes <denke>
Component: crontabsAssignee: Marcela Mašláňová <mmaslano>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-05-05 10:06:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Dolhay Denes 2008-05-03 09:57:24 UTC
Description of problem:

The bilt in delay.cron can give back "./000-delay.cron: line 13: [: x0: integer
expression expected" if $DELAY has a "0" value.

Suggestion: add one more checks for that too.

Result:

[ -f /etc/sysconfig/crontab ] && . /etc/sysconfig/crontab
if [ ! -z "$DELAY" ]; then
    if [ "x$DELAY" != "x0" ]; then
        # Create md5sum of hostname (static over system lifetime)
        md5sum="`echo ${HOSTNAME} | md5sum`"

        # Extract the first 3 hexdigits (12 Bit: 0-4095)
        hexvalue="${md5sum:0:3}"

        # Create decimal value
        decvalue="`printf "%d" "0x${hexvalue}"`"

        # Divide delay by factor
        T_DELAY=$[ ${decvalue} / ${DELAY} ]
        sleep $T_DELAY
    fi
fi
exit 0