-1

I am fololowing this link but this did not work for me .

My start up script is:

#!/bin/bash
java -jar AppDemo.jar

My stop script is:

#!/bin/bash
#Grabs and kill a process from the pidlist that was the word app

pid=ps aux | grep AppDemo | awk '{print $2}'
kill -9 $pid

Myscript for init.d is:

!/bin/bash
# AppDemo
#
# description: Start Jar on system boot

 case $1 in
    start)
    /bin/bash /usr/local/bin/AppDemo-start.sh
    ;;
    stop)
        /bin/bash /usr/local/bin/AppDemo-stop.sh
       ;;
        restart)
        /bin/bash /usr/local/bin/App-Demo.sh
        /bin/bash /usr/local/bin/App-Demo.sh
       ;;
    esac
    exit 0

this is now working for me. I don't know what I did wrong can anybody please help?

αғsнιη
  • 36,350

1 Answers1

0

To run a command/script at start/reboot you could also e.g. use a cronjob.
Run

sudo crontab -e

choose an editor (e.g. 2 for nano)
And add a line like

@reboot <path/to/your/script.sh>

Note: Anyway inform you first about environment variables etc because cron by default runs on a limited environment and you might need to add some paths to run your script correctly.

derHugo
  • 3,376
  • 5
  • 34
  • 52