I have a script that is running some package updates and I want to do a reboot after they are done. The only problem is there are executions that must happen after the reboot occurs. Obviously the script will no longer be running once the system is rebooted.

How can I continue what the script was doing after the reboot? Is there any setting that says nextBoot or anything like that where I could insert the contents of the rest of the script?

I know about /etc/init.d but this script is only going to be running once a month at most and I don't want the whole script to be running on boot.

thanks in advance!

  • I'm confused by the combination of AIX and RHEL and SUSE tags. – Jeff Schaller Jul 19 '17 at 12:28
  • These are the os flavors this script will be running on. – jacksonecac Jul 19 '17 at 12:30
  • You have one script that's going to update package son AIX, RHEL, and SUSE and reboot them and want to run something afterwards? (and oracle-linux?) – Jeff Schaller Jul 19 '17 at 12:37
  • yes that is correct, there is a post-update script that needs to be run – jacksonecac Jul 19 '17 at 12:37
  • If you know how long the reboot takes, you can try an at job. – ceving Jul 21 '17 at 7:41

That's quite a range of operating systems to cover, so my general suggestion would be to install "init" scripts for each OS that call a "phase 2" script that you maintain. This "phase 2" script checks for the existence of a post-update-script; if it exists, then it runs it and then deletes it. Your "phase 1 update" script would install this post-update-script when it's done and before the reboot.


You could use cron's @reboot extension (assuming cron you using supports them). The pre-reboot script could for example create a temporary file before reboot, which the after-reboot script checks before running the rest of the script.

  • 2
    Wouldn't cover AIX, unfortunately. – Jeff Schaller Jul 19 '17 at 13:37
  • 1
    I think you wants to do the task only once and not after every reboot. – ceving Jul 21 '17 at 7:45

You can create lock file (ie. /var/local/yourscript) in your script, and after each reboot ( cron @reboot) check of exist this file, if it exist run second script (or first with some parameter).

  • ... and delete the lock file so that you don't run again... – Jeff Schaller Jul 21 '17 at 17:39
  • Yes, in second script – Krzysztof Stasiak Jul 21 '17 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.