Sample Header Ad - 728x90

Automatically start a script while booting on OpenSuse 11

0 votes
1 answer
2285 views
I need the following sample script to run when OpenSuSe 11 is booting: #!/bin/sh i=0; while true; do "SOME COMMAND FOR SAVING i TO ANOTHER PLACE" &> /dev/null i=$((i+1)) sleep 1 done So basically just add 1 every second on a variable and then send the variable to another system. I saved this script at /bin/user/script.sh Starting the script from console works perfectly.. /bin/user/script.sh > /dev/null 2>&1 & First I added this line to the existing /etc/init.d/boot.local that comes with OpenSuSe, however this was not working so stable. Sometimes it was started and sometimes not. I thought because of user rights, but even after chmod 755 script.sh The problem continues. So then I made my own /etc/init.d/myscript Content of /etc/init.d/myscript: #! /bin/sh # # /etc/init.d/myscript # ### BEGIN INIT INFO # Provides: myscript # Required-Start: # Required-Stop: # Default-Start: 3 5 # Default-Stop: 0 # Short-Description: Start myscript while booting # Description: ... ### END INIT INFO # # # case "$1" in start) echo "Starting myscript." /bin/user/script.sh > /dev/null 2>&1 & ;; stop) echo "Stopping myscript." killall -9 script.sh ;; *) echo "Usage: $0 {start|stop}" exit 1 ;; esac Then I did the insserv command for my script: insserv myscript Starting and stopping from console works.. /etc/init.d/myscript start /etc/init.d/myscript stop but again no sign of life for myscript after booting. What am I doing wrong? How can I successfully run a script every time when the system starts? **Update 2015.11.12: This script is working and starting correctly on boot on OpenSuSe 11.**
Asked by Ñhosko (101 rep)
Nov 11, 2015, 05:01 PM
Last activity: Apr 13, 2025, 05:00 PM