LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2011, 02:02 PM   #1
Rawful
LQ Newbie
 
Registered: Jun 2011
Posts: 12

Rep: Reputation: Disabled
Running a program on startup


I have a program I have made, and I would like it to run as soon as the system is finished booting. I am using Ubuntu Mini Remix to recreate a LiveCD/USB stick. After booting, it drops me to a command line where I can enter "sudo qct" and it will run my program (which is called qct, and it has to be run as root).

I want this to be automated. Instead of going to a command line, I want it to run the program itself at that point. How would I go about doing this? I have read many tutorials about scripting but I cannot seem to get it to work.
 
Old 08-09-2011, 02:09 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Hello,

Click on System, Preferences, Sessions, and from there, select the "Startup Programs" tab, and you can add your program to be ran on boot.

Cheers,

Josh
 
1 members found this post helpful.
Old 08-09-2011, 02:11 PM   #3
Rawful
LQ Newbie
 
Registered: Jun 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
This distro is command-line only, no GNOME or Unity.
 
Old 08-09-2011, 02:34 PM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Ahh ok, that explains it

Does your distro contain the /etc/rc.d/init.d/ directory? It should, but I have never used your distro.... You could always move your script into that directory, then create links to your runlevel directories, such as /etc/rc.d/rc5.d/ and so forth. Or you could just move the script to /etc/rc.d/rc.local.

Cheers,

Josh
 
1 members found this post helpful.
Old 08-09-2011, 03:08 PM   #5
Rawful
LQ Newbie
 
Registered: Jun 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
There is:

/etc/init.d/
/etc/rc0.d/
/etc/rc1.d/
/etc/rc2.d/
/etc/rc3.d/
/etc/rc4.d/
/etc/rc5.d/
/etc/rd6.d/
/etc/rdS.d/

there is a rc.local file in /etc/


The script I am trying to run is this:
Code:
#!/bin/bash

qct
It needs to be run as root for the program to function.
 
Old 08-09-2011, 03:13 PM   #6
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Well in order to run it as root, you will have to manually enter your root password. Since you said your distro is command line only, you could place your script name within rc.local and go from there.
 
1 members found this post helpful.
Old 08-09-2011, 03:21 PM   #7
Rawful
LQ Newbie
 
Registered: Jun 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
So I would add a line containing "/etc/rc2.d/qctrun.sh" to rc.local?
 
Old 08-09-2011, 03:23 PM   #8
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
You can place your script anywhere, just make sure that your script is chmod'd to execute.
Code:
(in rc.local)
/path/to/script/qctrun.sh
Not sure how exactly it will work on your system, but with some tweaking, you can definitely figure it out.

Cheers,

Josh

Last edited by corp769; 08-09-2011 at 03:27 PM.
 
1 members found this post helpful.
Old 08-09-2011, 03:24 PM   #9
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,087

Rep: Reputation: 407Reputation: 407Reputation: 407Reputation: 407Reputation: 407
Just put /path/to/qct into /etc/rc.local before the final line exit 0 and it will be run as root after everything else has booted up. You'll have to adjust the path to your command, don't take "/path/to/" literally. Example:
Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/rawful/qct
exit 0
You can add error checking as you see fit.

Try it out. See if it works.
 
2 members found this post helpful.
Old 08-09-2011, 03:28 PM   #10
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Quote:
Originally Posted by tredegar View Post
Just put /path/to/qct into /etc/rc.local before the final line exit 0 and it will be run as root after everything else has booted up. You'll have to adjust the path to your command, don't take "/path/to/" literally. Example:
Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/rawful/qct
exit 0
You can add error checking as you see fit.

Try it out. See if it works.
Beat you to it
 
Old 08-09-2011, 03:35 PM   #11
Rawful
LQ Newbie
 
Registered: Jun 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
Greatly appreciate the assistance, guys. Trying it out now to see if I can get it working
 
Old 08-09-2011, 03:55 PM   #12
Rawful
LQ Newbie
 
Registered: Jun 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
Now it doesn't even boot as far as the command line. It sits at the ubuntu loading screen endlessly filling the same dots with orange and then white

It is probably trying to do what I told it to do, but I cannot see.

Last edited by Rawful; 08-09-2011 at 04:01 PM.
 
  


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
running program at startup noir911 Linux - General 2 01-09-2007 12:50 PM
running program at startup noir911 Linux - General 2 01-08-2007 08:46 PM
Running a program at startup allomeen Linux - General 5 02-15-2006 06:36 PM
running a program at startup beccala33 Linux - Newbie 3 04-25-2002 05:00 PM
running a program at startup beccala33 Programming 1 04-23-2002 04:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:30 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration