autorun program in c++
With what functions i can write my program in /etc/init.d with c++ to start every time the computer starts ? (like in windows with RegOpenKey,RegSetValueEx..............) ?
|
I'm sorry, this is pretty unclear. Linux does not use a registry like windows, typically starting a linux daemon is as easy as making an init script for the actual executable and linking it to the correct runtimes which is a process entirely done outside c++. For example how apache starts in your distribution (cat /etc/init.d/httpd or /etc/init.d/apache2 in all likelihood) you can compare that to sshd or mysql to get an idea of what is required and optional.
|
yes i know.but can i do this from c++ code,or manualy copy the program to /etc/init.d ?
|
If you just want to start something at boot-up, use rc.local. You can compile your program and place the binary in, say, /bin. Then edit /etc/rc.local and add a line like this:
/bin/my_prog & Remember to put the '&'. Else, your machine may hang while booting. |
Hi
Another easy way to run something at reboot is to use cron. Put something like this in your crontab: @reboot /bin/my_prog |
All times are GMT -5. The time now is 12:04 PM. |