• [^] # Re: petit bug

    Posté par . En réponse au journal Éteindre son serveur la nuit et l'allumer automatiquement le matin. Évalué à 2.

    Effectivement, ça peut même être bien simplifier avec un truc du genre :

    #!/bin/sh
    same_day=$(date +%s -d "today ${1}:${2}")
    next_day=$(date +%s -d "tomorrow ${1}:${2}")
    now=$(date +%s)
    if [ $same_day -gt $now ]; then
     reboot=${same_day}
    else
     reboot=${next_day}
    fi
    echo $reboot > /sys/class/rtc/rtc0/wakealarm

    https://linuxfr.org/users/barmic/journaux/y-en-a-marre-de-ce-gros-troll