Reputation: 466
I'm using Ubuntu 11.10. I've written a simple listener application in Java which runs properly (tested). Basically this java application in a loop that waits for an event every 60 seconds. After successfully jar-ing this file, I'm able to execute the file using
/usr/bin/java -jar /home/testuser/MyApp.jar
What I want to do is a create a shell script that starts this application when Ubuntu boots. My autostart.sh script is really simple:
#!bin/bash
/usr/bin/java -jar /home/testuser/MyApp.jar
Then I use the following commands to put it in the init.d directory:
#: sudo cp /home/testuser/autostart.sh /etc/init.d
#: chmod 777 /etc/init.d/autostart.sh
#: sudo update-rc.d /etc/init.d/autostart.sh defaults
Then I restart and use top to see if Java is running, but I dont see this. Does anyone know what the best way to implement this?
Using "ls -l /etc/rc?.d/*autostart" I get:
@hovanessyan: my output for that command is -
lrwxrwxrwx 1 root root 17 2012-03-19 14:26 /etc/rc0.d/K20autostart -> ../init.d/autostart
lrwxrwxrwx 1 root root 17 2012-03-19 14:26 /etc/rc1.d/K20autostart -> ../init.d/autostart
lrwxrwxrwx 1 root root 17 2012-03-19 14:26 /etc/rc2.d/S20autostart -> ../init.d/autostart
lrwxrwxrwx 1 root root 17 2012-03-19 14:26 /etc/rc3.d/S20autostart -> ../init.d/autostart
lrwxrwxrwx 1 root root 17 2012-03-19 14:26 /etc/rc4.d/S20autostart -> ../init.d/autostart
lrwxrwxrwx 1 root root 17 2012-03-19 14:26 /etc/rc5.d/S20autostart -> ../init.d/autostart
lrwxrwxrwx 1 root root 17 2012-03-19 14:26 /etc/rc6.d/K20autostart -> ../init.d/autostart
Upvotes: 0
Views: 2896
Reputation: 15363
Create an upstart job and set the appropriate run level(s). Look at the other jobs in /etc/init
with the .conf extensions for examples.
Upvotes: 1