LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-23-2010, 04:17 AM   #1
bzlaskar
Member
 
Registered: May 2006
Location: Bangalore, INDIA
Distribution: Fedora Core
Posts: 69
Blog Entries: 2

Rep: Reputation: 17
Question How To Start A Process on Bootup


[QUOTE=s&j;107336]
I have a program that I want to run as a service on my linux machine i.e. it should always be executing. After a system reboot it should start running automatically without any user intervention.

I was thinking of using cron to somehow schedule the program to launch after every reboot but I am not sure if that what I should be using.


We can also use crontab to run a job after system reboot.

Just make an entry in the cron as follows:

@reboot <yourscript.sh>

-Bz
 
Old 08-23-2010, 01:20 PM   #2
Road
Member
 
Registered: Jan 2002
Distribution: Debian Based only but have tried most others.
Posts: 82

Rep: Reputation: 15
Wow talk about bringing a post back from the dead, hopefully he figured it out after 8 years . Well since I was notified I might as well add some more now to this dated post. It looks as SysV is going to be finally be replaced in the next few years. Ubuntu has already gone that way by moving to upstart.

http://upstart.ubuntu.com/

Also if you just want your program or some script to start and you don't want to fuss with run level stuff just use /etc/rc.local

Lastly if you don't need the app to start until you logon to your gnome session in distro's like the latest Ubuntu (10.04) just use the gui session startup

System -> Setup -> Startup Applications


A few more cron special commands

@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".
 
Old 08-26-2010, 12:41 PM   #3
kingkoti
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Rep: Reputation: 0
will there be any problem if we give the path of the service in /etc/rc.local? ( /etc/rc.d/rc.local in few distros)
I mean. Is it the preferred way? if not, what is the preferred one.

Last edited by kingkoti; 08-26-2010 at 12:42 PM.
 
Old 08-26-2010, 01:09 PM   #4
Road
Member
 
Registered: Jan 2002
Distribution: Debian Based only but have tried most others.
Posts: 82

Rep: Reputation: 15
Pretty much always use full paths (it never hurts) and if you want to make it a bit more portable just make the paths variables so they can easily be changed. rc.local is kind of like the junk drawer made to catch situations like this so not much for standards. You can use it to call other scripts or write the script directly in the file. If you wanted to make a more standard approach make your own /etc/init.d startup script and then use something like update-rc.d to turn it on or off.

Last edited by Road; 08-26-2010 at 01:11 PM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to start a process with specific uid/gid during bootup? senthilpr_in Linux - Software 5 05-23-2007 11:22 PM
Root file system not being checked during bootup process SP7 Linux - Newbie 3 07-24-2006 01:23 PM
Fedrora 2: process bootup messages themarkg Fedora 4 08-16-2004 09:48 PM
How to stop LP process at bootup? britishnemesis Linux - Software 1 10-27-2003 01:04 AM
faster bootup process dieroboter Linux - Software 6 09-13-2003 12:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:06 PM.

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