Email: bknpk@hotmail.com Phone: +972-54-7649119
V

 

Useful script for debian linux, which can be used at system startup

The following describes a script that I run at startup on my debian.

Motivation:I run my web site on my own debian server. The domain is from no-ip and I need to update IP, when the ISP changes my IP. To do that I have a script, which senses the IP change and activates a program from no-ip to update that IP. All that is required is to start the script at startup and have it run on the background.



  1. The script is shown below.

    #! /bin/sh
    # /etc/init.d/blah
    #


    # Carry out specific functions when asked to by the system
    case "$1" in
      start)
        echo "Starting script init_my_web_ip "
        cd /home/pini/Home_2/bin_web
        pwd
        pgrep -f -x "perl Eli_debianip_update.pl 1.1.1.1" || (perl Eli_debianip_update.pl 1.1.1.1&)
        ;;
      stop)
        echo "Stopping script init_my_web_ip "
        my_id=`pgrep -f -x "perl Eli_debianip_update.pl 1.1.1.1"`
        echo "killing pid=$my_id"
        pgrep -f -x "perl Eli_debianip_update.pl 1.1.1.1" && kill -9 $my_id
        ;;
      *)
        echo "Usage: /etc/init.d/blah {start|stop}"
        exit 1
        ;;
    esac

    exit 0

  2. Note that the script checks if the process is already running, using the command pgrep. If the script is running, it will not be started again.

  3. Next we set the script permissions.
    chmod 755 /etc/init.d/init_my_web_ip.unx
  4. Last tell your debian to start the script using the update-rc command. First by just checking and than add it.
    #does nothing but check what we are doing.
    update-rc.d -n init_my_web_ip.unx defaults.
    #if okay update
    update-rc.d init_my_web_ip.unx defaults


Contact me now at:

  ...


I would be happy to offer my services. Call ASAP !


Home

debian script, which runs at system startup, to open a tunnel via ssh






Search This Site


Feedback This Site




new pages on this site