LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-11-2009, 02:23 PM   #1
mac1234mac
Member
 
Registered: Sep 2005
Posts: 183

Rep: Reputation: 30
how to run program automatically in a very small Linux


Hello,

I've got very small linux (I think it's based on Slackware) and I'd like
to run program at boot up (something like Autostart in Windoze). This
Linux is only console version and there are very few programs in it.
What would I have to add (install) to it (maybe nothing???) and how to use
it?.


Cheers.
 
Old 08-11-2009, 02:57 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Not a full explanation but should allow you to search for more. Details vary with distribution but along the lines of ...

Create a script in /etc/init.d, ideally based on /etc/init.d/skeleton, and create a symbolic link to it in /etc/rc<n>.d where <n> is the runlevel you want to start your program in with a name like SNNmyscript where NN is chosen to order it within the other S (for start) scripts to get the necessary sequence.

There are tools to help with this process, maybe referenced in /etc/init.d/skeleton. Perhaps the update-rc.d utility.

For a simpler approach (which will not integrate so well or give pretty console messages at boot time) you could add a line to start your program in /etc/init.d/rc.local
 
Old 08-11-2009, 03:09 PM   #3
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,948

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Using catkin's way will launch the application with root privileges which may not be what you want. If you don't want the application to run with root privileges, then you can edit your ~/.bash_profile file to include the launch command for your application. The application will then launch with user privileges every time the user logs in.

Last edited by kilgoretrout; 08-11-2009 at 03:10 PM.
 
Old 08-14-2009, 12:29 PM   #4
mac1234mac
Member
 
Registered: Sep 2005
Posts: 183

Original Poster
Rep: Reputation: 30
Thanks for all your hints. Very informative.
 
Old 08-14-2009, 12:52 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
If you want the program to start at boot as you wrote and do not want it to run with root privileges then use the su command in the boot script to "switch user".
Code:
su -l <username> -c <command>
The -l (letter l) simulates the environment the user would get when they logged in which may be essential.

The technique is often used for starting databases but best not look for such examples because few DBAs can write decent shellscript (for reasons I've never fathomed -- I guess they don't do much of it).

Last edited by catkin; 08-14-2009 at 12:55 PM. Reason: Amplification
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
GDB: Run program automatically kenneho Programming 5 12-05-2009 09:14 AM
how to run a program automatically when booting up? shj339 Linux - General 1 05-05-2008 05:10 AM
Run program a startup automatically shambler SUSE / openSUSE 2 09-13-2006 10:50 AM
Automatically run root program. Hammett Linux - Software 4 05-16-2004 12:45 PM
How do I automatically run at boot an X program or script cmisip Linux - General 4 01-05-2003 06:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:17 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