Ubuntu – Automatic script

bashcommand lineinitscriptssudo

I have an Ethereum node running and mining on a terminal in Linux. I want to create a script that will start up the node.sh roughly 2 minutes after startup. My script is in the home/chainskills/private/startnode.sh. I want this to be executed after startup. I have barely any knowledge of Linux. Please help me. I was told to go and create a script in the etc/init.d directory but I don't know how to. I am running this on a Ubuntu 18 on a mini-mac. I have followed the instructions on many pages on how to automate this script. I need to use the init.d and not a cronjob. Please help.

Best Answer

  • Use a cronjob:

    Run crontab -e and add following line:

    @reboot sleep 120 && /home/chainskills/private/startnode.sh > /home/chainskills/private/startnode.log 2>&1
    

    If you need to run your script as root user, run sudo crontab -e and add the line there.