Solved

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

Posted on 2008-10-11
8
298 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 200 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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 34

Accepted Solution

by:
Duncan Roe earned 300 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Fine Tune your automatic Updates for Ubuntu / Debian
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

705 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