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

Practical MySQL + PostgreSQL batch insert update insertOrUpdate

Table of contents 1. Baidu Encyclopedia 1. MySQL ...

How to configure user role permissions in Jenkins

Jenkins configuration of user role permissions re...

WeChat applet implements a simple calculator

WeChat applet's simple calculator is for your...

Detailed explanation of Vue.js directive custom instructions

Customize a demo command The syntax of Vue custom...

HTML/CSS Basics - Several precautions in HTML code writing (must read)

The warning points in this article have nothing t...

Sample code for using CSS to write a textured gradient background image

The page length in the project is about 2000px or...

The difference between MySQL execute, executeUpdate and executeQuery

The differences among execute, executeUpdate, and...

mysql8 Common Table Expression CTE usage example analysis

This article uses an example to describe how to u...

Quickly solve the problem that the mysql57 service suddenly disappeared

one, G:\MySQL\MySQL Server 5.7\bin> mysqld --i...

Solution to the garbled problem of web pages when the encoding is set to utf-8

Recently, when I was writing web pages with PHP, I...

Solution to the docker command exception "permission denied"

In Linux system, newly install docker and enter t...

Detailed explanation of CSS counter related attributes learning

The CSS counter attribute is supported by almost ...

Three uses and differences of MySQL not equal

Judgment symbols are often used in MySQL, and not...