View Full Version : Executing several bash scripts in succession even after reboot

May 17th, 2009, 03:35 AM

I am new to shell programming. I am trying to automate setting up a network using several scripts. Some of the scripts require to reboot in order to continue with the setup. Is it possible to enter another script as soon as the system reboots. Also, if the last line of the script is bash "anotherscript.sh" will "anotherscript.sh" start up ?

Thanks in advance.

May 17th, 2009, 04:37 AM
Not sure if this is what you want. ubuntu and many other linux distributions will run a script "/etc/rc.local" after all /etc/init.d boot scripts are finished. By calling your script from this file (or putting the code in /etc/rc/local itself) you can have your script run upon reboot. You could create a file that maintains the state of your installation process across reboots, and have your script read the file and run the appropriate code. Remember to have proper owner and permissions on your scripts.

As for your 2nd question, the short answer is yes. Actually, after anotherscript.sh finishes, execution will return to calling script. To prevent the return you can call the line with exec, i.e. "exec bash anotherscript.sh"

FYI, if you chmod +x a script and have #!/bin/bash as the first line, it is not necessary to call it as "bash script", it can be directly invoked by it's name.

Here is a really good bash tutorial you may be interested in:


There is also an older version of this guide in the ubuntu repositories. Or for downloadable version or other guides on the same site: http://tldp.org/guides.html

May 17th, 2009, 06:55 AM
Thanks so much lswb. Your solution seems perfect.