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 start multiple MySQL instances in CentOS 7.0 (mysql-5.7.21)

Configuration Instructions Linux system: CentOS-7...

Example code for implementing fullpage.js full-screen scrolling effect with CSS

When I was studying CSS recently, I found that I ...

About Nginx gzip configuration

The principle of nginx to achieve resource compre...

Implementation of Vue3 style CSS variable injection

Table of contents summary Basic Example motivatio...

Installation and configuration method of vue-route routing management

introduce Vue Router is the official routing mana...

A brief analysis of React Native startReactApplication method

In this article, we sorted out the startup proces...

In-depth understanding of JavaScript callback functions

Table of contents Preface Quick Review: JavaScrip...

How to check PCIe version and speed in Linux

PCIE has four different specifications. Let’s tak...

JavaScript to achieve full or reverse selection effect in form

This article shares the specific code of JavaScri...

mysql 8.0.18 mgr installation and its switching function

1. System installation package yum -y install mak...

Summary of common commands for Ubuntu servers

Most of the commands below need to be entered in ...

Limiting the number of short-term accesses to a certain IP based on Nginx

How to set a limit on the number of visits to a c...

Graphical steps of zabbix monitoring vmware exsi host

1. Enter the virtualization vcenter, log in with ...

MySQL View Principle Analysis

Table of contents Updatable Views Performance of ...