Solved

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

Posted on 2008-10-11
8
289 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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:ricardoelena
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
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.:

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now