Scheduled auto-reboot possible for Haiku?

Hi all,

Is there a way to auto-reboot Haiku once every 24 hours? We use Haiku daily to run a radio station, but VNC and FTP connectivity is lost after Haiku has been running for a couple days or more. I’d like to have the system auto-reboot at 4 AM or so every early morning, to help remedy the problem. Thanks,
Jeff

You can install cronie from haikudepot and use it to define a job to run at a certainhour everyday. I have not done that so I can’t provide more precise instructions, sorry

Did you report your problem to the haiku bugtracker (dev.haiku-os.org) with system logs if available?

You could execute this script on bootup or put it in ~/config/settings/boot/UserBootscript. It checks every 30 seconds if it’s 4:00 o’clock and reboots if it is. Before rebooting, it waits a minute to make sure it’s past 4:00 when you’ve rebooted to avoid an immediate reboot (in case you have a fast starting machine…):

 #!/bin/sh

while true ; do
	now=$(date +%H:%M)
	if [ $now == "4:00" ] ; then
		echo reboot
		sleep 60	# wait until it's past 4:00
		shutdown -r
	fi
	sleep 30
done
1 Like

Thanks guys,

I used the script and named it “autoboot”.

I’m pretty sure I opened a ticket on the connectivity problem a few years ago, or maybe it was already an open ticket I saw. The problem may have been fixed by now, I’m not sure. I wouldn’t dare attempt to update the Haiku version to a “fixed” one though, since the Tunetracker system we used was bought as a complete system and seems somewhat integrated with the Haiku system as far as I can tell.

The shutdown command can also delay the reboot if you calculate the number of seconds until 4:00. It is possible to use a command like…

#!/bin/bash
shutdown -r -d $(( `date --date '4:00 tomorrow' +%s` - `date +%s` ))
5 Likes

Oh, even nicer! :slight_smile:

Hi all,

Is there an easy way in Haiku to schedule a computer reboot once every 24 hours?
Thanks, Jeff.

Do you need something different than the last time you asked? :stuck_out_tongue:

1 Like

Wow, I’m getting a little concerned about my memory. I had no idea I posted the first one, not even that long ago.

2 Likes

It’s almost 2 years ago now and there were a lot of things going on at the time. Recovering from COVID lockdowns and stuff.

2 Likes

Use a shell scrip in the boot folder or try out the yab development language to make a script you are asking for.

as @lelldorin said you can put a script, or its symlink, into /boot/home/config/settings/boot/launch

the script could be something similar:

#! /bin/bash

sleep 1d && timeout 1m alert --stop --modal "Do you want to reboot your system now?" "No" "Yes" 1>/dev/null

# wait 1 day, prompt a modal alert, if confirmed or w/o an answer in 1 minute, it reboots

[ $? -ne 0 ] && shutdown -r
1 Like

There is a cron equivalent on HaikuPorts (I think it’s called cronie) and the shell command to reboot appears to be shutdown -r.

Sure, and it’s more elegant to do such a task using cron, “sleep” is a brutal way but using system tools without installing nothing more ( if i remember well timeout is not a bash built-in, but i think is brought within gnutils)

1 Like

I put this script in the /boot/home/config/setting/boot/launch and made it executable, but for some reason the computer didn’t restart at 2:30 AM. The script is running; I checked in Terminal using “ps” command.

#!/bin/sh

while true ; do
now=$(date +%H:%M)
if [ $now == “2:30” ] ; then
echo reboot
sleep 60 # wait until it’s past 2:30
shutdown -r
fi
sleep 30
done

1 Like

Try with

if [ $now = "02:30" ] ; then

What about Lrrr’s suggestion. looks much neater?

Thanks to all for your help. I got rid of that extra “=” and rebooted. If it still doesn’t work, I’ll try Lrrr’s script.

That one could be improved a bit but it depends on how accurate it needs to be. If the script is run after midnight then it will delay for more than 24 hours. If you need to guarantee that it reboots at 4AM then it would need a few lines.

#!/bin/bash
delayTime=$(( `date --date '4:00 tomorrow' +%s` - `date +%s` ))
(( delayTime > 86400 )) && (( delayTime -= 86400 ))
shutdown -r -d $delayTime