Perfect Solution for No rc.local File in Linux

Perfect Solution for No rc.local File in Linux

Newer Linux distributions no longer have the rc.local file. Because it has been turned into a service.

Solution:

1. Set up rc-local.service

sudo vim /etc/systemd/system/rc-local.service
[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local
[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99
[Install]
 WantedBy=multi-user.target

2. Activate rc-local.service

sudo systemctl enable rc-local.service

3. Add startup service

Manually create or copy an existing /etc/rc.local and grant execution permissions

#!/bin/sh -e
# 
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# The following is the command to be started at startup /home/selfcs/anaconda3/bin/python /home/selfcs/t.py > /home/selfcs/auto.log 

exit 0
#Give the script execution permission sudo chmod +x /etc/rc.local

Summarize

The above is the perfect solution to the problem of no rc.local file in Linux introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Detailed explanation of the difference between /etc/rc.local and /etc/init.d/rc.local in Ubuntu system
  • Solve the problem that /etc/rc.local does not execute when starting centos7

<<:  MySQL full-text fuzzy search MATCH AGAINST method example

>>:  React implements the principle analysis of the three stages of loading, loading, completion, loading failure

Recommend

How to represent various MOUSE shapes

<a href="http://" style="cursor...

Why MySQL chooses Repeatable Read as the default isolation level

Table of contents Oracle Isolation Levels MySQL I...

The difference between this.$router and this.$route in Vue and the push() method

The official document states: By injecting the ro...

Six ways to reduce the size of Docker images

Since I started working on Vulhub in 2017, I have...

Detailed explanation of using JavaScript WeakMap

A WeakMap object is a collection of key/value pai...

SQL implementation of LeetCode (183. Customers who have never placed an order)

[LeetCode] 183.Customers Who Never Order Suppose ...

onfocus="this.blur()" is hated by blind webmasters

When talking about the screen reading software op...

MySQL query specifies that the field is not a number and comma sql

Core SQL statements MySQL query statement that do...

jQuery implements all shopping cart functions

Table of contents 1. Select All 2. Increase or de...

How to install and connect Navicat in MySQL 8.0.20 and what to pay attention to

Things to note 1. First, you need to create a my....

HTML Basics: HTML Content Details

Let's start with the body: When viewing a web ...

nginx+tomcat example of accessing the project through the domain name

I was curious about how to access the project usi...

JS+AJAX realizes the linkage of province, city and district drop-down lists

This article shares the specific code of JS+AJAX ...

How to handle the tcp_mark_head_lost error reported by the Linux system

Problem Description Recently, a host reported the...

CSS code abbreviation div+css layout code abbreviation specification

Using abbreviations can help reduce the size of yo...