Run a script on boot using systemd on Ubuntu 18.04

Previous versions of Ubuntu had /etc/rc.local. that get executed after system boot.

On Ubuntu 18.04, you can use systemd to start a bash script on system boot.

Create file

Add

Create file /etc/rc.local with

You can replace “touch /root/OK” with whatever command you need to execute.

Make it executable with

Reload systemd

Enable the service

Now reboot the server, you will see /root/OK get created.

Add a Comment

Your email address will not be published. Required fields are marked *