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 01: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,488
    Any reason you can't simply add a sleep 30 at the appropriate point?
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    Conkybots: Interactive plugins for your Conkys!

  3. #3
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,356
    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. #4
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,488
    Simplistic rather than optimistic but it might be all that's needed
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    Conkybots: Interactive plugins for your Conkys!

  5. #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 07:17 AM.

  6. #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
  •