Tuesday, December 17, 2024
HomeSolarisSolaris system administrationCreate a basic Solaris runtime control script

Create a basic Solaris runtime control script

Runtime control scripts start and stop services when the system changes run levels. Well constructed rc scripts handle at least start and stop as command line arguments.


Runtime control scripts are just regular shell scripts and anything that is valid for the shell that executes it is valid in the script. Note that it is advisable to use the statically linked /sbin/sh as the interpreter so that the script can run without the dynamic libraries. The command interpreter can be defined on the first line of the script by preceeding it with the #! characters. For more information, see Understanding Solaris runtime control scripts.

The following code is a runtime control script example for starting and stopping a SunONE web server located in /usr/iplanet/webserver/https-www.tech-recipes.com

#!/sbin/sh
#
# web server runtime control script
#
# https://www.tech-recipes.com
#

case "$1" in
'start')
/usr/iplanet/webserver/https-www.tech-recipes.com/start
;;

'stop')
/usr/iplanet/webserver/https-www.tech-recipes.com/stop
;;

'restart')
/usr/iplanet/webserver/https-www.tech-recipes.com/restart
;;

*)
echo "Usage: $0 { start | stop | restart }"
exit 1
;;

esac
exit 0

Quinn McHenry
Quinn McHenry
Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!