设为首页收藏本站

安徽论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 12140|回复: 0

ubuntu开机自启动服务设置

[复制链接]

76

主题

0

回帖

240

积分

中级会员

Rank: 3Rank: 3

积分
240
发表于 2022-3-26 10:59:34 | 显示全部楼层 |阅读模式
网站内容均来自网络,本站只提供信息平台,如有侵权请联系删除,谢谢!
在ubuntu 下创建服务及自启动的方法:
1. 在 [/lib/systemd/system] 创建sandtable.service 服务,
  1. [Unit]
  2. Description=/etc/sandtable Compatibility
  3. Documentation=man:systemd-sandtable-generator(8)
  4. ConditionFileIsExecutable=/etc/sandtable
  5. After=network.target

  6. [Service]
  7. Type=forking
  8. ExecStart=/etc/sandtable start
  9. TimeoutSec=0
  10. RemainAfterExit=yes
  11. GuessMainPID=no

  12. [Install]
  13. WantedBy=multi-user.target  
  14. Alias=sandtable.service
复制代码
2. 创建启动脚本
在[/etc]文件夹下创建sandtable启动脚本,切记加上[脚本后&], 保证服务不影响系统启动,不然那可能导致系统无法正常启动后果。
  1. #!/bin/sh
  2. /home/ubuntu/setup >> /home/ubuntu/test.log&
复制代码
3. 启动服务
  1. systemctl start sandtable.service #启动服务

  2. systemctl status sandtable.service #查看服务是否启动

  3. systemctl enable sandtable.service #开机运行服务

  4. systemctl is-enabled sandtable.service #查询服务是否开机启动
复制代码
4 服务常用命令
  1. systemctl is-enabled servicename.service #查询服务是否开机启动

  2. systemctl enable *.service #开机运行服务

  3. systemctl disable *.service #取消开机运行

  4. systemctl start *.service #启动服务

  5. systemctl stop *.service #停止服务

  6. systemctl restart *.service #重启服务

  7. systemctl reload *.service #重新加载服务配置文件

  8. systemctl status *.service #查询服务运行状态
复制代码
5.桌面系统的开启与关闭
  1. // 关闭桌面系统
  2. sudo systemctl set-default multi-user.target
  3. sudo reboot

  4. // 打开桌面系统
  5. sudo systemctl set-default graphical.target
  6. sudo reboot
复制代码
6. 桌面版设置的wifi 在下边路径进行修改替换即可
  1. /etc/NetworkManager/system-connections
复制代码
到此这篇关于ubuntu开机自启动服务设置的文章就介绍到这了,更多相关ubuntu开机自启动内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
                                                        
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
免责声明
1. 本论坛所提供的信息均来自网络,本网站只提供平台服务,所有账号发表的言论与本网站无关。
2. 其他单位或个人在使用、转载或引用本文时,必须事先获得该帖子作者和本人的同意。
3. 本帖部分内容转载自其他媒体,但并不代表本人赞同其观点和对其真实性负责。
4. 如有侵权,请立即联系,本网站将及时删除相关内容。
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表