What Is Script Daemon Mode?
- Daemon mode ensures the script will relaunch when it was terminated by external forces (e.g., service crash, power loss) once the device returns to a normal state. Exceptions include:
- The device runs out of power and is never recharged
- The device cannot boot
- Jailbreak state is lost after reboot
- The device is in Safe Mode
- The device has a passcode and is rebooted
- Manually terminated by user
- Script terminated due to a runtime error
- Daemon mode starts earlier than the boot-time script. After an unexpected reboot, you may add the following code at the beginning of your script to ensure the screen is unlocked before running:
while (device.is_screen_locked()) do
device.unlock_screen()
sys.msleep(1000)
end
sys.toast("Screen unlocked. Script starts.")
-- Your script continues below
-- ...