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 03-05-2011, 12:08 PM   #1
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Rep: Reputation: 0
Arrow Autostart programs inquires!


I write code check.sh and add the following line as it's first line:
Quote:
#!/bin/sh -e
Then make it's permission as executable
Then coped it to the following destination:
Code:
cp Scripts/check.sh /etc/init.d
I symbolic link as the following:
Code:
ln -s /etc/init.d/check.sh /etc/rc0.d
ln -s /etc/init.d/check.sh /etc/rc1.d
ln -s /etc/init.d/check.sh /etc/rc2.d
ln -s /etc/init.d/check.sh /etc/rc3.d
ln -s /etc/init.d/check.sh /etc/rc4.d
ln -s /etc/init.d/check.sh /etc/rc5.d
ln -s /etc/init.d/check.sh /etc/rc6.d
I add bash check.sh to Auto-start.

Q1:Why doesn't it run as Auto-start program?! What is the problem, please need some help.Is there something wrong or missing?

Q2:I found the program which in the /etc/rc0.d : /etc/rc6.d
prevoiused by a letter and number of 2 digit
e.g.
K74bluetooth
K20winbind
S70pppd-dns
S30killprocs

Is that letters mean something?

Last edited by MODYSAMA; 03-05-2011 at 12:22 PM.
 
Old 03-05-2011, 02:09 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,520

Rep: Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502
You didn't say your distro, but I guess it's ubuntu as in your profile.
1.
In this case, you can either put the full path your script in /etc/rc.local, or you can use update-rc.d to create the needed symlinks for the various runlevels
2.
The letters mean (S)tart and (K)ill a service on boot and shutdown respectively and the number the follows is the priority that it will happen.

You can take a look here to how to write a script to run at system startup.

Regards
 
1 members found this post helpful.
Old 03-06-2011, 10:18 AM   #3
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Sorry for my bad,
Yes,kubuntu 10.10

I add the line:
Quote:
bash /home/sok/Scripts/check.sh
before exit 0 of /etc/rc.local

also add it into Autostart.

And symbolic link to rc5.d with priority 60:
Code:
ln -sf /home/sok/Scripts/check.sh /etc/rc5.d/S60check.sh
I restart but still no effect.
What's wrong, please?

Last edited by MODYSAMA; 03-06-2011 at 10:19 AM.
 
Old 03-06-2011, 11:14 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,520

Rep: Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502
Hi,

First of all verify that your script runs without errors when invoked from CLI. To check, just run:
Code:
/home/sok/Scripts/check.sh
It it does, then you can use:
Code:
/home/sok/Scripts/check.sh
in /etc/rc.local. And make user that /etc/rc.local is executable.
And of course in this case, you don't need to mess with the various runlevels.
 
1 members found this post helpful.
Old 03-06-2011, 03:24 PM   #5
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Hello sir,
I did what you said.
terminal:
Code:
/home/sok/Scripts/check.sh
it run correctly.
autostart,add as a program:/home/sok/Scripts/check.sh

add
Code:
/home/sok/Scripts/check.sh
before exit 0 of rc.local

everything was okey. and rc.local is executable and the .sh is also executable.
I restart the system no new.

what's the problem.!!

Last edited by MODYSAMA; 03-06-2011 at 03:25 PM.
 
Old 03-06-2011, 05:57 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,520

Rep: Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502
Hi,

How are you sure that it isn't running on boot? Maybe you need to specify some environment variables needed for your script to run on boot. Or post your script here, so we can have a look at it?
Also you can add in your script something like:
Code:
/bin/touch /tmp/test.txt
i.e. create a file in /tmp, just to see if it actually runs by etc/rc.local.

Regards
 
1 members found this post helpful.
Old 03-07-2011, 08:23 AM   #7
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Thank you.You are right.
It Run and created the test file.
I think the problem with my script code.
Here is the code:
Code:
Removed
I want that code to run parallel to "Motion Detection" program which is correctly work @ startup.
I think the problem is:
check.sh is start before motion program is began so it always execute the else statement.

I want to make it runnable as infinite loop, till I manually end process. To be parallel with "motion".
Any suggestion?

Last edited by MODYSAMA; 03-07-2011 at 07:16 PM.
 
Old 03-07-2011, 10:10 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,520

Rep: Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502
Quote:
I think the problem is:
check.sh is start before motion program is began so it always execute the else statement.
No, whatever is in /etc/rc.local runs last, i.e. after everything else has started through the various services.
I don't know how you start that "Motion Detection" program, but I'm sure your script runs after the "Motion Detection" program has started. Besides if it executes the else statement there should be a /tmp/Inside_Else.txt file created.

If you want it to run in a loop, uncomment the following 2 lines:
Quote:
--snip
#while [ true ]; do
--snip--
#done
 
1 members found this post helpful.
Old 03-07-2011, 07:19 PM   #9
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Thanks bathory perfect,
Thanks my god it work and correctly,
Do you know how can I stop that process from terminal ?
 
Old 03-08-2011, 01:37 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,520

Rep: Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502
Hi,

You can run:
Code:
pkill sciptname
Regards
 
1 members found this post helpful.
Old 03-08-2011, 07:33 AM   #11
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Thank you,
I tried it but didn't work

It done by
Code:
ps -aux |grep  /home/sok/Scripts/check.sh
then get the id of that process
then kill it by
Code:
sudo kill -9 <pid>
Many thanks for being helpful.
 
  


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
PCLinuxOS - Autostart Programs voip4africa Linux - Distributions 1 04-02-2010 10:36 AM
Autostart programs in KDE reefa Linux - Software 0 11-30-2007 01:44 AM
autostart programs under xfce 4.2 nicon Linux - Newbie 3 03-25-2006 03:02 PM
autostart programs at login asgari22 Fedora 7 01-31-2005 05:12 PM
autostart programs mcd Slackware 1 09-12-2003 05:58 PM


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