How to create a startup process in Ubuntu

With server management, startup batch / job / process is very important for disaster recovery or just simple to reduce administrator work. So, in this topic, we will show you how to create them with a few line of code

  1. Create a script file with the extension is .sh file
  2. Fill the first line of script with #!/bin/bash . It’s the instruction for the server to use /bin/bash is the default interface for all command is run
  3. After the first line, we can do anything we want the server do. It will be written by bash script language
  4. Save the file and change the permission to 755
  5. Create a symlink to /etc/init.d folder:
    sudo ln -s < absolute path to the sh script > /etc/init.d/< shortname for script >
  6. Run the command below to register the script
    sudo update-rc.d < shortname of script > defaults
  7. We can test again by reboot the server and check the syslog in /var/log/syslog if your script is printing out or return something

Have fun and give us any questions when you have any troubles with them!