Use runit in Ubuntu 16.04 LTS

2 years, 4 months ago DevOps, Ubuntu

Last 2 years, I am using runit to run any script automatically during booting. When I was using Ubuntu 14.04 in my server, I wasn't having any issue. But in Ubuntu 16.04, an issue has been found. runit plays with upstart which was default in Ubuntu 14.04. But in Ubuntu 16.04, upstart has been replaced with systemd. So, runit isn't working normally. But the issue can be fixed as follows:

1. At first, we will install upstart. As upstart and systemd can't work together, so system will be removed automatically. Play the command on terminal: 

sudo apt-get install upstart-sysv

2. Now runit can be installed by this command:

sudo apt-get install runit

3. runit has been installed. Now we will configure it to run python3 /home/maateen/test.py during booting. Let's make a folder for this:

mkdir /etc/sv/en_maateen

4. In this folder, we have to create a run script:

nano /etc/sv/en_maateen/run

And have to write some code in it:

#!/bin/bash
python3 /home/maateen/test.py

5. Let's make it executable:

chmod +x /etc/sv/en_maateen/run

6. The last thing is to make a symbolic link between runit folder and upstart folder:

ln -s /etc/sv/en_maateen /etc/service/en_maateen

That's all. If you find any issue, let me know please.

Previous Next
Comments
Have you read the comment guideline?

Give me useful, constructive criticism. Spot a typo or an error? Let me know and I will correct it.