[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: One-time cron output?



+ Raphael Hertzog (Sun, 15 Mar 2009 09:31:45 +0100):

> > IMHO the right thing to would be for mlocate (in locate mode, not in
> > updatedb mode) to issue a warning if the DB was too old instead of the
> > way you suggested.

> Sending the warning only when updatedb is skipped and when the DB is
> already quite old seems like a good compromise.

This is actually a very good suggestion, and I’ve ended up doing exactly
that, but limiting the warnings at one per week at most:

    if [ "$ON_BATTERY" -eq 1 ]; then
        DAYS_OLD=$(( (`date +%s` - `stat --printf=%Y $DATABASE`)/(3600*24) ))
        if [ $DAYS_OLD -ge 7 ] && [ `date +%u` -eq 1 ]; then # Only on Mondays
            cat >&2 <<-EOF
                mlocate: system on battery power, not updating database.
                mlocate: warning: database more than $DAYS_OLD days old.
                EOF
            exit 1
        fi
        exit 0 # Don't let cron complain without a warning of what was wrong
    fi

How does that sound?

> Why only in locate mode? It does this already AFAIK but it doesn't tell
> the user why it's old.

It is findutil’s locate that does it, and not mlocate. I could submit a
wishlist against mlocate upstream that they’d copy this behavior. For
now, the above will have to suffice.

Thoughts?

-- 
- Are you sure we're good?
- Always.
        -- Rory and Lorelai


Reply to: