This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Starting bash script on boot

Hi all,

Hopefully its an easy fix, I'm trying to start a bash script at startup that will run forever (while system is online).

I have a script, called statupdate

I have located it in /etc/init.d/

I have given it execute permissions

I have then put in a link to it under /etc/init.d/RC3.d/S99statupdate

This worked, but the system boot sequence never finished because the script started kept looping, preventing the system boot sequence to continue.

I then created another script called startupdate

that script simply started the main statupdate script. I tried with the following:

./statupdate &

OR

nohup ./statupdate & 

I swapped out the S99statupdate with S99startupdate (and gave it execute permissions)

The exact same issue occured.

Can anyone point out what I'm doing wrong?

Cheers,
Pazu


This thread was automatically locked due to age.
Parents
  • I have tried the following but get an error 'unknown service' when trying to add with chkconfig

    #!/bin/bash
    #
    # Run-level Startup script for the LCD Stat Updater
    #
    # chkconfig: 345 91 19
    # description: Startup/Shutdown LCD Stat Updater

    # if the executables do not exist -- display error

    if [ ! -f /etc/init.d/statupdate ]
    then
            echo "LCDStatusMon startup: cannot start"
            exit 1
    fi

    # depending on parameter -- startup, shutdown, restart 
    # of the instance and listener or usage display 

    case "$1" in
        start)
            # LCDStatusMon  startup
            echo -n "Starting LCD Status Monitor: "
            /etc/init.d/statupdate
            echo "OK"
            ;;
        stop)
      # LCDStatusMon shutdown
            echo -n "Shutdown LCD Status Monitor: "
            pkill -f statupdate
            echo "OK"
            ;;
        reload|restart)
            $0 stop
            $0 start
            ;;
        *)
            echo "Usage: $0 start|stop|restart|reload"
            exit 1
    esac
    exit 0
Reply
  • I have tried the following but get an error 'unknown service' when trying to add with chkconfig

    #!/bin/bash
    #
    # Run-level Startup script for the LCD Stat Updater
    #
    # chkconfig: 345 91 19
    # description: Startup/Shutdown LCD Stat Updater

    # if the executables do not exist -- display error

    if [ ! -f /etc/init.d/statupdate ]
    then
            echo "LCDStatusMon startup: cannot start"
            exit 1
    fi

    # depending on parameter -- startup, shutdown, restart 
    # of the instance and listener or usage display 

    case "$1" in
        start)
            # LCDStatusMon  startup
            echo -n "Starting LCD Status Monitor: "
            /etc/init.d/statupdate
            echo "OK"
            ;;
        stop)
      # LCDStatusMon shutdown
            echo -n "Shutdown LCD Status Monitor: "
            pkill -f statupdate
            echo "OK"
            ;;
        reload|restart)
            $0 stop
            $0 start
            ;;
        *)
            echo "Usage: $0 start|stop|restart|reload"
            exit 1
    esac
    exit 0
Children
No Data