TABLE OF CONTENTS
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.
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 following script in /usr/sbin/testscript.sh using your favorite text editor (like nano):
#!/bin/bash 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
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.
[Unit] Description=A description for your custom service goes here After=network.target [Service] Type=simple ExecStart=/bin/bash /usr/sbin/testscript.sh TimeoutStartSec=0 [Install] WantedBy=default.target
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
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: https://invite.gg/SkySilk
CLICK TO DEPLOY AN UBUNTU LINUX VPS
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article