Sure you can. It would help to know what OS you are running.
You will need to do a few things. All these things are based on an HPUX system. But should be similar to yours
You will need to edit the /etc/inittab file to add it to the bootup.
Create a script and put it in a directory similar to /sbin/init.d, may be diff place on your box.
Create a link to the startup directory similary to /sbin/rc3.d linked to the script in /sbin/init.d. The link name will start with an "S" and a number and the script name. Like S342myscript.
You will also need a Kill script in a lower directory probably in /etc/rc1.d. This script may be called K342myscript.
So you will have 3 files basically.
/sbin/init.d/myscript # actual script here
/etc/rc3.d/S342myscript # link to above script for startup on bootup.
/etc/rc1.d/K342myscript # link to above script for kill script on shutdown.
You can look at the syntax of other scripts in this file to include the "start" and "stop" functionality with your script so you can stop it and restart it when it gets out of whack.
Look at the /sbin/init.d/cron script. This is a fairly short example of a good script to copy. There should also be a template file in there as well.
Here are a few posts that give some help.
https://www.unix.com/showthread.php?s...hlight=inittab