Find the answer to your Linux question:
Results 1 to 6 of 6
i have a script that runs on boot... Code: #! /bin/sh # /etc/init.d/myCode ### BEGIN INIT INFO # Provides: myCode # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2013
    Posts
    3

    delaying startup script


    i have a script that runs on boot...
    Code:
    #! /bin/sh
    # /etc/init.d/myCode
    
    ### BEGIN INIT INFO
    # Provides:          myCode
    # Required-Start:    $remote_fs $syslog
    # Required-Stop:     $remote_fs $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Script to start a program at boot
    # Description:       This script calls to /home/pi/myCode
    ### END INIT INFO
    
    # Carry out specific functions when asked to by the system
    case "$1" in
      start)
        # run application you want to start
        /home/pi/myCode
        ;;
      stop)
        # kill application you want to stop
        killall myCode
        ;;
      *)
        echo "Usage: /etc/init.d/myCode {start|stop}"
        exit 1
        ;;
    esac
    
    exit 0
    how can i make this script to run say, 30 seconds after boot
    Last edited by farai; 05-30-2013 at 02:35 PM.

  2. #2
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,638
    Any reason you can't simply add a sleep 30 at the appropriate point?
    "I used to be with it, then they changed what it was.
    Now what was it isn't it, and what is it is weird and scary to me.
    It'll happen to you too."

    Grandpa Simpson



    The Fifth Continent

  3. #3
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,422
    Adding a sleep would be an optimistic approach.
    Think: Slower systems or parallel start of initscripts.

    Can you name the dependencies of your myCode?
    ie: What needs to be started before in order for myCode to work?
    You must always face the curtain with a bow.

  4. $spacer_open
    $spacer_close
  5. #4
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,638
    Simplistic rather than optimistic but it might be all that's needed
    "I used to be with it, then they changed what it was.
    Now what was it isn't it, and what is it is weird and scary to me.
    It'll happen to you too."

    Grandpa Simpson



    The Fifth Continent

  6. #5
    Just Joined!
    Join Date
    May 2013
    Posts
    3
    Any reason you can't simply add a sleep 30 at the appropriate point?
    i tried to use the sleep but its not doing what i want, It just pauses boot sequence for awhile and then continues. i dont want this script to run while booting but i want it to run after everything boots
    Last edited by farai; 05-31-2013 at 08:17 AM.

  7. #6
    Just Joined!
    Join Date
    May 2013
    Posts
    3
    ie: What needs to be started before in order for myCode to work?
    yes, adding a sleep in the script is not yielding desired rusults.

    myCode opens a file sored on a computer, reads whats in that file and sends to the serial port. when i put myCode script on start up, it gives an error "File not found" which means the code was executed on startup before it could get access to all the files stored on the comuputer. So, basically i am looking for a way to delay script and run it when all the files are accessible.......After start up...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •