Welcome to the Dash Forum!

Please sign up to discuss the most innovative cryptocurrency!

Auto restart the Masternode

Discussion in 'Masternode Guides' started by DrkMiner, Nov 29, 2014.

  1. DrkMiner

    DrkMiner Member

    Joined:
    Jun 7, 2014
    Messages:
    204
    Likes Received:
    63
    Trophy Points:
    88
    To insure your MN is up all times or auto start after reboot, I wrote a small script that checks every 2 minutes if the Node is up and restart it if not.

    Recently Digitaloncean been doing some upgrades and Nodes were rebooted.

    Check if the service darkcoind is running and if not start it
    1. Create a mn_autostart.sh file with this code:
    Code:
    #!/bin/sh
    SERVICE='darkcoind'
    
    if ps ax | grep -v grep | grep $SERVICE > /dev/null
    then
      echo "$SERVICE is already running!"
    else
      ./darkcoind
    fi
    
    2. Upload to same directory as your ./darkcoind
    3. Chomd file to 744
    Run the script every 2 minutes - crontab
    1. On your SSH screen type:

    export EDITOR=nano
    crontab -e

    2. Paste the code at the end
    Code:
    */2 * * * * sh /root/mn_autostart.sh >/dev/null 2>&1
    
    3. Save and exit
    4. Make sure you have the correct path to the script. If you login as a user you will have to change the dir from "root" to that user.​
     
    • Like Like x 3
  2. crowning

    crowning Well-known Member

    Joined:
    May 29, 2014
    Messages:
    1,430
    Likes Received:
    2,009
    Trophy Points:
    183
    Quite useful.

    BTW, darkcoind does NOT need superuser-privileges, so better run it as a 'normal' user.
     

Share This Page