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
Solved

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

Posted on 2008-10-11
8
292 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
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

808 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