LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-10-2010, 10:43 AM   #1
vbx_wx
Member
 
Registered: Feb 2010
Posts: 181

Rep: Reputation: 16
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..............) ?
 
Old 03-10-2010, 11:20 AM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
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.

Last edited by rweaver; 03-10-2010 at 11:23 AM.
 
Old 03-10-2010, 11:51 AM   #3
vbx_wx
Member
 
Registered: Feb 2010
Posts: 181

Original Poster
Rep: Reputation: 16
yes i know.but can i do this from c++ code,or manualy copy the program to /etc/init.d ?
 
Old 03-10-2010, 12:17 PM   #4
sarin
Member
 
Registered: May 2001
Location: India, Kerala, Thrissur
Distribution: FC 7-10
Posts: 354
Blog Entries: 2

Rep: Reputation: 34
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.
 
Old 03-11-2010, 03:12 AM   #5
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
Hi

Another easy way to run something at reboot is to use cron. Put something like this in your crontab:

@reboot /bin/my_prog
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to autorun a CD or Program golfadict Linux - Newbie 5 11-06-2009 02:22 PM
HOWTO autorun a program on start up? kodaku Linux - Software 6 08-12-2004 09:40 PM
AutoRun Program in XWindows zael Linux - Newbie 3 02-09-2004 06:49 AM
autorun application program on hotplug kevinatkins Linux - Software 0 02-08-2004 07:44 AM
autorun a program in tty3 LynX Linux - Newbie 2 11-09-2002 04:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration