LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 03-09-2009, 01:03 PM   #1
mas123
LQ Newbie
 
Registered: Mar 2009
Posts: 14

Rep: Reputation: 0
startup scripts


Hello,
I want to run an executable c file on start up. Im using ubuntu. I read few how to on this topic, but things are not working so far. These are the steps i followed:
1. create myscript.sh in etc\init.d

myscript.sh
#run c file
./start

2. give the file permissions:
chmod +x myscript.sh
3. create a symbolic link in rc3.d:
sudo ln -s /etc/init.d/myscript.sh /etc/rc3.d/S500myscript.sh
sudo ln -s /etc/init.d/myscript.sh /etc/rc3.d/K001myscript.sh

Currently I am in runlevel 2, I switch to runlevel 3 by the following comman:
sudo init 3
I expect my c code to run..but this is not the case
I also tried this command:
sudo update-rc.d myscript.sh defaults

but no luck...any idea what i am missing?

Thank you inadvance,
MAS

Last edited by mas123; 03-09-2009 at 01:04 PM.
 
Old 03-09-2009, 01:06 PM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
#run c file
./start
try to give the whole path to start or first cd to the directory which contains start
 
Old 03-09-2009, 01:54 PM   #3
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
what about manually start your c file
#/etc/init.d/myscript.sh start, is this successfully start your c file? if yes check below mention things

did u check whether the startup script added on runlevel 3
#chkconfig --list | grep myscript.sh
or
#cd /etc/rc3.d, and check whether the script is exist or not

Last edited by kirukan; 03-09-2009 at 02:00 PM.
 
Old 03-09-2009, 02:26 PM   #4
sureshsujatha
Member
 
Registered: Mar 2009
Posts: 40

Rep: Reputation: 15
Try adding an echo command to your start.sh. That should tell you for a fact whether/not your start.sh is being invoked or not.

If not - you probably aren't supplying the path right!

Last edited by sureshsujatha; 03-14-2009 at 12:29 AM.
 
Old 03-11-2009, 01:08 AM   #5
mas123
LQ Newbie
 
Registered: Mar 2009
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by repo View Post
try to give the whole path to start or first cd to the directory which contains start
initially, i had start in the etc\init.d folder
i cd to the directory which contains start:
cd /home/MAS/Desktop

I also included echo commands but things arent working yet
 
Old 03-11-2009, 01:11 AM   #6
mas123
LQ Newbie
 
Registered: Mar 2009
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by kirukan View Post
what about manually start your c file
#/etc/init.d/myscript.sh start, is this successfully start your c file? if yes check below mention things

did u check whether the startup script added on runlevel 3
#chkconfig --list | grep myscript.sh
or
#cd /etc/rc3.d, and check whether the script is exist or not
maually starting myscript.sh works

I cd to /etc/rc3.d and the soft link is there named S99MAS

Last edited by mas123; 03-11-2009 at 01:12 AM.
 
Old 03-13-2009, 09:37 PM   #7
b_schelberg
LQ Newbie
 
Registered: Mar 2009
Location: Queensland, Australia
Distribution: Linpus
Posts: 3

Rep: Reputation: 0
Similar problem - Apache HTTP Server on Linpus

I have a similar problem - I want to automatically start and stop Apache HTTP Server on Linpus.
I've added a script to /etc/init.d.
I've run chkconfig to add the service.
I've checked that the script exists in /etc/rc5.d (I'm assuming this is the relevant run level - executing runlevel just gives me "unknown" for some reason..?)
I can start and stop the service using:
service apache start
service apache stop

But when I reboot, the script doesn't run. Where do I go from here?
Thanks,
Bernie
 
  


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
Startup Scripts metallica1973 Linux - Software 2 04-21-2008 10:40 PM
Mandriva startup scripts (need to add something to startup before X starts) thunderweasel Mandriva 3 01-01-2006 12:55 AM
startup scripts iomari SUSE / openSUSE 2 10-19-2005 01:38 AM
Startup scripts MadnessASAP Linux - Software 2 12-15-2004 07:09 PM
Startup scripts celticselph Slackware 5 04-08-2004 07:23 AM

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

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