• Compute

    Configure a popular Linux OS or use popular developer Tools

  • Cloud hosting
    Cloud hosting

    Host a VPS in the Cloud in seconds

  • Collaborate, CMS, CRM`s
    Collaborate, CMS, CRM`s

    Collaborate with these popular CMS, CRM & collaboration tools

  • Database & E-Commerce
    Database & E-Commerce

    Create a database or an E-Commerce environment in seconds

[Basic] How to: Start a Program or Script on Linux Automatically on Boot with systemd


If you have a Linux server and have a need to configure a service or program to automatically start on boot, this guide will demonstrate how to do so. This guide will be helpful to those that run critical services on their Linux machines. You will learn 

how to ensure that those services always auto-start, even after an unplanned reboot.

How to start a program on Linux automatically on boot

We will be utilizing systemd for this task. First, we will create a sample script. Next, we will create a system unit that references our sample script. Finally, we will tell systemd, to automatically run our script (service unit) on system startup.

Start by logging onto your VPS via SSH. You may follow this guide to help you SSH into your SkySilk VPS

Create the sample script or program that we want to automatically start on boot

Create the following script in /usr/sbin/testscript.sh using your favorite text editor (like nano):

d=$(date +%Y-%m-%d-%s)
echo "$d" >> ~/"$d".log
exit 0

Make sure that the script is executable:

chmod +x /usr/sbin/testscript.sh

Create a system unit (also known as a service)

We will now create a system unit that references the above test script. This system unit is how systemd will know to run the test script at system boot.

Create the following file in /etc/systemd/system/test.service.  Make sure you reference the script that you created above and that you save the system unit with a ".service" extension.

Description=A description for your custom service goes here

ExecStart=/bin/bash /usr/sbin/testscript.sh


Configure your service to automatically start on boot

Reload the systemctl daemon:

 systemctl daemon-reload

Tell systemd to enable your custom system unit:

 systemctl enable test.service

Confirm that your test service was created successfully:

systemctl --all | grep test.service

Start your service:

systemctl start test.service 

Test your service with a reboot!

Go ahead and do a test reboot of your server. The service you configured should auto-start as the server boots up. At this point your all done with the configuration!  

Join our Private Discord Chat to chat with, as well as find community assistance from other Verified SkySilk Users:


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.