I have a project where I'd like to plug in (to power) the Raspberry Pi, have it start running a Python program to write data to a USB stick, and shut itself down after 104 hours. It will NOT be connected to a network.
For example. I plug in the Pi at 9:00 AM on Monday morning, it runs all week, and shuts itself down at 5:00 PM on Friday.
I thought about doing this with cron as described in this entry... Automatic shutdown of Pi based on timer ...but given that the Pi will not be connected to a network, I'm not sure if this will work.
Any ideas on how to handle the automatic shutting down? Thanks!
Note: I am using a Raspberry Pi 3B+ running Rasbian Buster.
@reboot
line in a crontab withsudo shutdown -h +6240
that will activate in 60*104 minutes from now.@reboot /sbin/shutdown -h +6240
cron
is theat command
for one-time tasks that you want to run at a specific time. Runningshutdown
with a delay is a good answer for your purpose though. But I am wondering if your PI has a realtime clock backup up by battery since it will not be able to do network time synchronization. Thenat
may not be a good option.