0

I have some tutorials on how to run a script at startup on ubuntu server, but it keeps failing with status=203

Here is the script.sh file i wrote in /etc/init.d :

### BEGIN INIT INFO
# Provides:            Multicraft
# Required-Start:       
# Required-Stop        
# Should-Start:         
# Should-Stop:          
# X-Start-Before:       
# X-Start-After:        
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# X-Interactive:        
# Short-Description:    Multicraft daemon
# Description:          Starts the Multicraft daemon at system startup
### END INIT INFO

. /home/minecraft/multicraft/bin/multicraft -v start

exit 0

I have also run the "sudo update-rc.d script.sh defaults" command.

Can anyone please tell me what i am doing wrong?

P.S. It should be noted that when i manually run this command, the program launches and everything works as expected:

sudo /home/minecraft/multicraft/bin/multicraft -v start

2 Answers2

0

Try adding Sleep into your script.

sleep 60
./home/minecraft/multicraft/bin/multicraft -v start
exit 0

OR

sleep 60
cd /home/minecraft/multicraft/bin/
sudo ./multicraft -v start
exit 0

OR

sleep 60
cd /home/minecraft/multicraft/bin/
sudo multicraft -v start
exit 0

Please increase the sleep time if above code does not work.(if you are root user no need to use sudo)

Possible duplicate of "Startup Applications" not working

gaganyaan
  • 201
  • 1
  • 8
0

Ok i found what was the problem: I did not write #!/bin/sh in the first line of the script.sh. And this is the script that actually works:

#!/bin/sh
### BEGIN INIT INFO
# Provides:             Multicraft
# Required-Start:       
# Required-Stop        
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Multicraft daemon
# Description:          Starts the Multicraft daemon at system startup
### END INIT INFO

start() {
  ./home/minecraft/multicraft/bin/multicraft -v start
}

stop() {
  ./home/minecraft/multicraft/bin/multicraft -v stop
}

case "$1" in
  start)
    start
  ;;
  stop)
    stop
  ;;
*)

esac
exit 0

Thanks for your help @editinit though.