1

I want my c++ program to run automatically when the operating system loaded , i mean when the system starts working .. I am using linux(ubutu) I have no idea to do that ? any idea may help .. thanks in advance

emartel
  • 7,712
  • 1
  • 30
  • 58
sana
  • 125
  • 5
  • 15
  • 2
    This question is off-topic here. It's not a programming question, it's a system administration question. Given you're on Ubuntu, http://askubuntu.com/ might be a good fit. – John Dibling Nov 15 '12 at 14:49

2 Answers2

4

(The fact that your program is written in C++ is irrelevant to this answer.)

Simply add a symbolic link to your executable in /etc/init.d/.

E.g. if your program is in /home/username/soft/myprog, run:

ln -s /home/username/soft/myprog /etc/init.d/

Make sure the file is executable.

Philippe
  • 9,582
  • 4
  • 39
  • 59
2

An alternate way that might be helpful

Open your .bashrc file (That can be found in the home directory i.e ~/.bashrc)
Add to it the line :

./program_executable_path

Also note that the program must have execute permission. You can grant the permission by using chmod:
$chmod u+x program_executable_path

axiom
  • 8,765
  • 3
  • 36
  • 38