Fixing rc.local Tasks That Stop Some Time After Boot

Using a DNSPod DDNS script as the example, this troubleshooting note traces an rc.local task’s unexpected exit to the shell’s -e option and records the workaround used.

My server uses DNSPod, and since its IP address is dynamic, I need DDNS.
I use a shell-script-based DDNS program that implements DDNS through DNSPod's standard API. I've forgotten the program
Previously, I used corn to run it every 2 minutes.
Later, I used sleep to run it every two minutes.
But then I found that the process would disappear a few hours after each day's reboot…
After some trial and error, I solved the problem.
The problem was in the first line of rc.local:

    #!/bin/sh -e

The “-e” option means “stop on error.” So, whenever the ping gets a little high and an error occurs, it stops.
The fix is simply to remove “-e.”

Discussion

View discussion on GitHub

Built with Hugo
Theme Stack designed by Jimmy