openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
3.98k stars 3.47k forks source link

busybox: need support for /etc/cron.daily so that packages may install into there #4569

Closed pprindeville closed 4 years ago

pprindeville commented 7 years ago

Some packages (like rrdtool and logrotate) benefit from being able to install a script that gets run daily, for data-reduction, log rotation, temporary file cleanup, etc.

Having packages modify /etc/crontabs/root with sed seems perilous. Easier to let each package have its own /etc/cron.daily/$(PKG_NAME) if it so desires.

pprindeville commented 7 years ago

Maintainer: @nbd168

feckert commented 5 years ago

@pprindeville Using this with the busybox cron does not work on OpenWrt as in other distribution (debian) So I added a PR https://github.com/openwrt/packages/pull/8178 to use in OpenWrt the micrond from freifunk. This will do what you want.

karlp commented 5 years ago

I added a script to my "first boot" scripts that sets this up. You need to include run-parts from the busybox config, and cron.

# Make sure that we have periodic cron support
# We plan to have
cron_periodic() {
    mkdir -p /etc/cron.d/daily
    mkdir -p /etc/cron.d/weekly
    grep -q -F "run-parts /etc/cron.d/daily" /etc/crontabs/root || {
        echo "crond daily entry not found, adding"
        local MYMIN=$(expr $(hexdump -n 2 -e '/2 "%u"' /dev/urandom) % 60)
        local MYHOUR=$(expr $(hexdump -n 2 -e '/2 "%u"' /dev/urandom) % 24)
        echo "$MYMIN $MYHOUR * * * run-parts /etc/cron.d/daily" >> /etc/crontabs/root
    }
    grep -q -F "run-parts /etc/cron.d/weekly" /etc/crontabs/root || {
        echo "crond weekly entry not found, adding"
        local MYMIN=$(expr $(hexdump -n 2 -e '/2 "%u"' /dev/urandom) % 60)
        local MYHOUR=$(expr $(hexdump -n 2 -e '/2 "%u"' /dev/urandom) % 24)
        local MYDAY=$(expr $(hexdump -n 2 -e '/2 "%u"' /dev/urandom) % 7)
        echo "$MYMIN $MYHOUR $MYDAY * * run-parts /etc/cron.d/weekly" >> /etc/crontabs/root
    }
}
neheb commented 4 years ago

micrond was merged. closing.

karlp commented 4 years ago

to clarify, "no solution has been provided that uses the system cron, but a completely separate parallel daemon is now available, that would let you do this"