Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Copyright © 2021 Benoît Boudaud https://miamondo.org/contact
- #This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
- # License as published by the Free Software Foundation, either version 3 of the License, or any later version.
- #This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
- # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- # You should have received a copy of the GNU General Public License along with this program.
- # If not, see <http://www.gnu.org/licenses/>
- # ----------------------------------------------------------------------------------------------------------------------
- poweroff=$(date -d "00:00" +%s) # Correspond à l'heure d'extinction
- time_before_poweroff=$[$poweroff - $(date +%s)] # Calcul du temps restant avant extinction.
- if [ $time_before_poweroff -lt 0 ] # Si le temps restant est négatif, cela signifie que l'extinction est passée.
- then # Alors, on rajoute un jour (86400 secondes) et on recalcule.
- time_before_poweroff=$[($poweroff+86400) - $(date +%s)]
- fi
- sleep $time_before_poweroff # Le script se met en pause jusqu'à l'extinction.
- # Puis, à l'heure convenue, il lance la commande rtcwake.
- rtcwake -l -m off -s 25200
- # ----------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement