Ubuntu boot auto-start service settings

Ubuntu boot auto-start service settings

How to create a service and auto-start it in Ubuntu:

1. Create sandtable.service service in [/lib/systemd/system],

[Unit]
Description=/etc/sandtable Compatibility
Documentation=man:systemd-sandtable-generator(8)
ConditionFileIsExecutable=/etc/sandtable
After=network.target
 
[Service]
Type=forking
ExecStart=/etc/sandtable start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
 
[Install]
WantedBy=multi-user.target  
Alias=sandtable.service

2. Create a startup script

Create a sandtable startup script in the [/etc] folder. Remember to add [&] after the script to ensure that the service does not affect the system startup, otherwise it may cause the system to fail to start normally.

#!/bin/sh
/home/ubuntu/setup >> /home/ubuntu/test.log&

3. Start the service

systemctl start sandtable.service #Start the servicesystemctl status sandtable.service #Check whether the service is startedsystemctl enable sandtable.service #Start the servicesystemctl is-enabled sandtable.service #Check whether the service is started

4 Common service commands

systemctl is-enabled servicename.service #Query whether the service is started at boot systemctl enable *.service #Startup service systemctl disable *.service #Cancel startup systemctl start *.service #Start service systemctl stop *.service #Stop service systemctl restart *.service #Restart service systemctl reload *.service #Reload service configuration file systemctl status *.service #Query service running status

5. Open and close the desktop system

// Shut down the desktop system sudo systemctl set-default multi-user.target
sudo reboot
 
// Open the desktop system sudo systemctl set-default graphical.target
sudo reboot

6. The wifi settings of the desktop version can be modified and replaced in the following path

 /etc/NetworkManager/system-connections

This is the end of this article about Ubuntu startup service settings. For more relevant Ubuntu startup content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Writing a shell script in Ubuntu to start automatically at boot (recommended)
  • How to add and delete startup items in Ubuntu
  • How to set up a startup script on Ubuntu 14.04

<<:  Detailed explanation of the solution to the problem that the content pointed to by the iframe's src does not refresh

>>:  Pure CSS to achieve cool neon light effect (with demo)

Recommend

WeChat applet date and time component (year, month, day, hour, and minute)

This article example shares the specific code of ...

Detailed steps to install web server using Apache httpd2.4.37 on centos8

Step 1: yum install httpd -y #Install httpd servi...

Example of Vue transition to achieve like animation effect

Table of contents Results at a Glance Heart Effec...

About the problem of dynamic splicing src image address of img in Vue

Let's take a look at the dynamic splicing of ...

Solve the problem that ElementUI custom CSS style does not take effect

For example, there is an input box <el-input r...

Detailed explanation of mysql scheduled tasks (event events)

1. Brief introduction of the event An event is a ...

MySQL inspection script (must read)

As shown below: #!/usr/bin/env python3.5 import p...

Layim in javascript to find friends and groups

Currently, layui officials have not provided the ...

MYSQL database basics - Join operation principle

Join uses the Nested-Loop Join algorithm. There a...

Detailed explanation of Vue routing router

Table of contents Using routing plugins in a modu...

Summary of learning Docker commands in one article

Table of contents Introduction Mirror repository ...

CentOS 6 uses Docker to deploy Zookeeper operation example

This article describes how to use docker to deplo...

MySQL database advanced query and multi-table query

MySQL multi-table query Add a worksheet -- User t...

Detailed explanation of MySQL transactions and MySQL logs

Transactional Characteristics 1. Atomicity: After...

mysql 8.0.19 winx64.zip installation tutorial

This article records the installation tutorial of...