?
Solved

Init.d  and Scripts : Starting a Script before of others

Posted on 2008-10-11
8
Medium Priority
?
301 Views
Last Modified: 2013-12-15
Dear Experts,

I have a Script in order to run  2 applications, one is in order to   have communication with a gsm modem, the other  is to have control for an equipment.  
 I want to start my script before the all other programs or  in the end of all programs,  because I need have a serial communication and have an information obtained by the equipment but is necessary start (or in the end) more slowly to have the correct answer  

what can I do?


cheers,

my script is:

#!/bin/sh
start() {
      /home/ipn/datalogger/extraccion/mareografod&
        /home/ipn/datalogger/transmision/gsmcomm&
}      
stop() {
      echo -n "stoping services..."
      /sbin/ifdown -a
}
restart() {
      stop
      start
}      

case "$1" in
  start)
        start
      ;;
  stop)
        stop
      ;;
  restart|reload)
        restart
      ;;
  *)
      echo $"Usage: $0 {start|stop|restart}"
      exit 1
esac

exit $?

0
Comment
Question by:hernan007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 19

Assisted Solution

by:jools
jools earned 600 total points
ID: 22694723
What distro are you using?

Redhat can be configured by adding it so chkconfig controls it; you can put the following like in your script;

   # chkconfig: 2345 10 90
This tells it to be run in levels 2,3,4&5, start is 10, end is 90.

Or you can do it manually by copying it to the run level you want it to start at and naming it something like;
   /etc/rc2.d/S15myscript

More detail can be given if you let us know your distro.

0
 

Author Comment

by:hernan007
ID: 22694889
iools,  thanks

Im using  debian lenny  with an AMD Geode lx800 processor ,

is possible run my script after 3 minutes  that  the complete system is loaded??

cheers,
0
 

Author Comment

by:hernan007
ID: 22694896
the name of my Script is   S50mareografod  
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 19

Expert Comment

by:jools
ID: 22695057
you mean after all the run scripts have started?

Just add it to the rc.local script on your system then.
0
 
LVL 35

Accepted Solution

by:
Duncan Roe earned 900 total points
ID: 22695805
Init will start the scripts in order, and doesn't itself have a facility to delay by an amount of time. But you can put a sleep command in the final script so it waits 3 minutes before doing anything, if you think that's really necessary.
You might want to arrange that a console is enabled for login before this sleep.
You could be better off having the early script (that does the setting up) create a file when setup is complete and the final script wait for that file to appear (in a small sleep loop say). Guessing some amount of time to wait is always a bit hit and miss.
0
 

Author Comment

by:hernan007
ID: 22702885
Thanks

Now  I have my  lines

home/ipn/datalogger/extraccion/mareografod&
/home/ipn/datalogger/transmision/gsmcomm&

in the start section in rc.local script   but it not work ..my lines not are loaded

I think that is necessary have the script in the end when the system is loaded in other case the communication with my data logger is incomplete (I have files with not completed information).

in the sleep command my serial ports works?  or all the system is affected ?

thanks ..

 
0
 
LVL 19

Expert Comment

by:jools
ID: 22705217
What happens when you run rc.local.

Can you check the startup logs for errors.
Is the missing "/" for `home/ipn/datalogger/extraccion/mareografod&`
a typo???

0
 
LVL 3

Expert Comment

by:Ricardo Elena
ID: 22736970
an easy way is to put your script location in the file /etc/rc.local or /etc/boot.local if your linux is Suse
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question