I have a Shell script that I want to run on boot. Every time that I start the device It'll run the script in the background. The script contains a while true loop and suppose to run constantly, at least until the device will be turned off. This is the script :
#!/bin/bash
cd /home/.../
while true
do
sh ./update_logs.sh
sleep 1
done
After of plenty of searches I've came up with too much information which made a salad in my head. I've been advised to get to this folder /etc/init.d
and put down my script there by using special pattern (LSB-compliant) which looks like this :
!#/bin/sh
start () {
echo "application started";
./helloworld # you should use an absolute path here instead of ./
}
stop () {
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage start|stop";
esac
exit $?
Make the script executable by chmod +x, then make A symbolic link for the file by typing ln -s /etc/rc.d/init.d/run_update.sh /etc/init.d/rc5.d/S90run_update
This supposed to be the "hard way" while the "easy way" is putting my script in a folder /etc/rc.local
where it shall boot my script after the main boot process.
Well, I don't have this kind of folder. What I to have in etc
folder is rc.d
which leads to sub folders : init.d
rc0.d
rc1.d
rc2.d
... rc6.d
If the solution is the hard way by writing the code above, what is the minimum that I need to include in it? since I see different type of codes which include ### with descriptions and run levels I have a Linux Red Hat 4.6.3-2.