Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 2438

Raspberry Pi OS • Setting Bookworm to shutdown and startup at fixed time using RTC

$
0
0
Hi,

I'm trying to power down a Pi that is running a display screen for my Home Assistant when no one is there.

I started to learn to setup automated shutdown and wake up using RTC - https://www.linux.com/training-tutorial ... arm-clock/

So first I made a script in /usr/local/bin/shutwake.sh that contains:

Code:

#!/bin/bash#define PATH and SHELL due to calling from root crontabPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin#clear any wakealarmssh -c "/usr/bin/echo 0 > /sys/class/rtc/rtc0/wakealarm"#set boot to tomorrows 0655sh -c "/usr/bin/echo `/bin/date '+%s' -d '0655 tomorrow'` > /sys/class/rtc/rtc0>#shutdown at current timeshutdown -h now
Followed by creating a cron task:

Code:

sudo crontab -e
and adding at the end:

Code:

# run script that shuts down Pi at 2200 every night and boots it at 065505 22 * * * /usr/local/sbin/shutwake.sh
However it doesn't seem to work. Can someone help me figure out how to either get an error code (there doesn't seem to be anything in Bookworm that puts cron errors in 'mail') or point out what error/assumption I'm making?

Statistics: Posted by Baenwort — Thu Dec 28, 2023 3:19 pm



Viewing all articles
Browse latest Browse all 2438

Trending Articles