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
  • Should you really be trying to source the file (as opposed to running it)? – steeldriver Feb 6 '16 at 23:22
  • I know close to nothing in ubuntu, so please explain me what is the difference between sourcing a file and running a file. :) – Amine Kchouk Feb 6 '16 at 23:39
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

  • I tried what you told me to do but it is still failing and it gives me the error "Exec format error". Here is the exact script.sh that i have: pastebin.com/0s3Vx8kP (i tried with both "Sleep" and "sleep") – Amine Kchouk Feb 7 '16 at 3:49
  • update: there is no space between dot and slash . ./home/minecraft/multicraft/bin/multicraft -v start – editinit Feb 7 '16 at 7:58
  • Okay i'll try that – Amine Kchouk Feb 7 '16 at 17:05
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.