I'm writing a shell script in bash. At some point in the script, it detects that the machine needs to be rebooted before continuing. It issues:
When the machine comes back up, there is is more work that this script needs to do. How do I configure something to continue doing the work in this script?
I'm assuming that there is some place that I can write a shell script such that it will get executed at the next reboot. Where is such a place? I see that cron has an @reboot directive. I also know that services such as Apache are started on boot by upstart. Would either of those be appropriate mechanisms? If so, how would it be triggered?
This script only needs to run once, not every reboot. So it will have to go somewhere that just runs on the next reboot, or be able to remove itself once it has run.
This question asks about how to save your application state for after reboot. My script doesn't have much state, so I can manage that. I just need to know how to have this script trigger something to run after the next reboot.
My specific version is Ubuntu Linux 14.04. The original script is started on the command line by a system administrator (as opposed to running from cron).