1

So once I log into my Ubuntu VM I launch my application by doing a

sudo app

Now I want my application to get started while booting. I tried it by creating an rc. script but nothing seems to work. Can someone point me to the correct way of getting it done?

Also my application has to run sudo. Hoping auto start will have the runlevel as root

  • Is this a GUI or CLI application? – Louis Matthijssen May 2 '14 at 23:09
  • Its a C program... i just want to launch a binary.. like "a.out" – Curious Guy 007 May 2 '14 at 23:22
  • So have you tried editing /etc/rc.local (sudo nano /etc/rc.local) and adding your command before the line containing exit 0? You don't need sudo here because all commands in this file are executed as root by default. – Louis Matthijssen May 2 '14 at 23:25
  • Thanks .. i added this to rc.local. /path_to_script/run.sh exit(0) It doe not come up on bootup, but after the bootup if i do a sudo ./rc.local.. it works. What am i doing wrong ? – Curious Guy 007 May 3 '14 at 0:00
  • File names are really important here. Are you sure you've editted /etc/rc.local? Also, you don't put exit 0 yourself there, but you put your command above the exit 0 that's already there. – Louis Matthijssen May 3 '14 at 6:49
0

You can try it with Upstart (/etc/rc.local doesn't work for me either).

Example:

author "Your name goes here - optional"
description "What your daemon does shortly - optional"

start on started dbus
stop on stopping dbus

# console output  # if you want daemon to spit its output to console... ick
respawn # it will respawn if crashed/killed

script
   echo "Hello world!" > /home/username/test.txt # without root permissions
   sudo -u root fdisk -l > /home/username/fdisk.txt # with root permissions
end script

You would put that in /etc/init/myUpStart.conf.

Further details:

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.