Giter VIP home page Giter VIP logo

Comments (2)

TOLDOTECHNIK avatar TOLDOTECHNIK commented on August 16, 2024

You can create a crontab job that runs every day at a specifig time.

Unfortunately we did not implement it in the current setup by default, so you need to do a little bit of work.

  1. Create an init.d script to run the cron service on startup:

nano /etc/init.d/S90crond

#!/bin/sh

CRON_JOB="30 22 * * * /root/poweroff.sh"

case "$1" in
        start)
                printf "Starting cron ... "
                mkdir -p /var/spool/cron/crontabs
                echo "$CRON_JOB" > /var/spool/cron/crontabs/root
                start-stop-daemon -S -q -m -b -p /var/run/dcron.pid --exec /usr/sbin/crond -- -f
                echo "done."
                ;;
        stop)
                printf "Stopping cron ..."
                start-stop-daemon -K -q -p /var/run/dcron.pid
                echo "done."
                ;;
        restart)
                $0 stop
                sleep 1
                $0 start
                ;;
        *)
                echo "usage: $0 {start|stop|restart}"
                ;;
esac

To make it simple, the cron job definition is also stored in the init script. For crontab scheduler definitions you can look at www.crontabgenerator.com for easily create the desired pattern.

  1. Make the init.d script executable:
    chmod +x /etc/init.d/S90crond

  2. Create the shutdown script:

nano /root/poweroff.sh

#!/bin/sh
poweroff &
exit 1

BTW: Putting the script into the root folder may not the best choice, but we leave it for now.

  1. Make the shutdown script executable:
    chmod +x /root/poweroff.sh

  2. Reboot your system.

Ensure to have the system time set correctly (e.g. internet sync) - else you have to setup the cron job with a delta t.

from buildroot-webkit.

momochihammer avatar momochihammer commented on August 16, 2024

Thanks for providing such fine details. From the information I gleaned from the web, it seems that I shouldn't really need to shutdown the RPi so I didn't use your script. I'm sure it would have done a great job.

Thanks again.

from buildroot-webkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.