参考:https://wiki.gentoo.org/wiki/Systemd

systemd 支持普通用户定义的 unit[s] 开机启动

  • systemctl --user enable/disable/start/stop/daemon-reload... xxx.timer/xxx.service...

注:

  • --user 不可省略,因为默认是执行 systemctl [--system],对于系统级 unit[s] 来说,不必显式添加 --system 选项

用户自定义的 unit[s] 可以放置在如下四个位置

  • /usr/lib/systemd/user:优先级最低,会被高优先级的同名 unit 覆盖
  • ~/.local/share/systemd/user
  • /etc/systemd/user:全局共享的用户级 unit[s]
  • ~/.config/systemd/user:优先级最高

注:

  1. 用户级 unit 与系统级 unit 相互独立,不能互相关联或依赖
  2. 用户级 unit 运行环境用 default.target,系统级通常用 multi-user.target
  3. 即使用户不登陆,其定制的服务依然会启动

示例:backup-work.timer

[Unit]
Description=daily backup work
RefuseManualStart=no
RefuseManualStop=no [Timer]
#系统异常关机错过的定时任务,是否后续补救
Persistent=false
#每次开机 10 分钟之后开始生效
OnBootSec=10min
#每天 11:30 执行
OnCalendar=Mon-Fri *-*-* ::
Unit=backup-work.service [Install]
WantedBy=default.target

示例:与 timer 配套的 unit(backup-work.service

[Unit]
Description=daily backup work
RefuseManualStart=no
RefuseManualStop=yes [Service]
Type=oneshot
ExecStart=/home/<user>/scripts/backup-work.sh

...

拾遗:systemctl --user的更多相关文章

  1. Redis命令拾遗二(散列类型)

    本文版权归博客园和作者吴双共同所有,欢迎转载,转载和爬虫请注明原文地址 :博客园蜗牛NoSql系列地址  http://www.cnblogs.com/tdws/tag/NoSql/ Redis命令拾 ...

  2. 基础拾遗------redis详解

    基础拾遗 基础拾遗------特性详解 基础拾遗------webservice详解 基础拾遗------redis详解 基础拾遗------反射详解 基础拾遗------委托详解 基础拾遗----- ...

  3. Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details

    thinkphp 在Apache上配置启用伪静态,重启Apache1 restart 竟然失败了,报错 Job for httpd.service failed because the control ...

  4. unixLike命令拾遗

    针对在日常工作过程中,发现的学习的漏洞和忘记的知识,进行拾遗. 编辑命令 一.vim操作 1.进入编辑模式 在光标移到将要编辑处,点击i,进入编辑模式 2.退出编辑模式 按esc或者crtl+c退出编 ...

  5. 基础拾遗------webservice详解

    基础拾遗 基础拾遗------特性详解 基础拾遗------webservice详解 基础拾遗------redis详解 基础拾遗------反射详解 基础拾遗------委托详解 基础拾遗----- ...

  6. Centos7中systemctl命令详解

    Linux Systemctl是一个系统管理守护进程.工具和库的集合,用于取代System V.service和chkconfig命令,初始进程主要负责控制systemd系统和服务管理器.通过Syst ...

  7. 【搬运】systemctl 命令完全指南

    Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器. Systemd是一个系统管理守护进程.工具和库的集合,用于取代System V初始进程.Systemd的功能是 ...

  8. CentOS 7 启动、重启、chkconfig等命令已经合并为systemctl

    CentOS 7系统服务启动.重启.设置服务启动项命令以合并为,systemctl . 现在用service 或/etc/init.d/命令,重启,重新启动,停止等没效果,因为命令合并为systemc ...

  9. Ubuntu 和 Redhat / Fedora 服务管理命令对比表(附Fedora16新的服务管理工具systemctl )

    以 apache/httpd 服务作为例子 任务 Red Hat / Fedora Ubuntu Ubuntu (with sysv-rc-conf or sysvconfig) 立即启动/停止某服务 ...

随机推荐

  1. 52、saleforce 导入csv文件

    Load Data Using the Custom Object Import Wizard 1. 2. 3. 4. 5. 6.然后就导入成功了

  2. 4、jQuery面向对象之简单的插件开发

    1.alert例子 (function($){ $.alert = function(msg){ window.alert(msg); } $.fn.alert = function(msg){ wi ...

  3. Missing artifact net.sf.json-lib:json-lib:jar:2.4

    Missing artifact net.sf.json-lib:json-lib:jar:2.4 出现上述这种错误就是JAR没有引入进来 这时候发现是因为JDK版本的问题,所以需要在加一句 < ...

  4. 模板引擎的简单原理template

    ​ var templateStr = "我的名字叫<%=name%>我是一只小狗,今年<%=age%>岁."; var data = { name:'旺财 ...

  5. HashCode方法整理

    哈希表这个数据结构想必大多数人都不陌生,而且在很多地方都会利用到hash表来提高查找效率.在Java的Object类中有一个方法: 1 public native int hashCode(); 根据 ...

  6. Jlink 接口定义

    JTAG有10pin的.14pin的和20pin的,尽管引脚数和引脚的排列顺序不同,但是其中有一些引脚是一样的,各个引脚的定义如下. 1. 引脚定义 Test Clock Input (TCK) -- ...

  7. 点读系列《jmeter官方用户手册》

    官网:http://jmeter.apache.org/usermanual/ 说明:十八元件.十九属性.二十函数,涉及清单内容暂未仔细阅读,个人觉得一是仅供使用参考,二是适合单独写文章来解读 一.让 ...

  8. 转 Python - openpyxl 读写操作Excel

    Python - openpyxl 读写操作Excel   openpyxl特点   openpyxl(可读写excel表)专门处理Excel2007及以上版本产生的xlsx文件,xls和xlsx之间 ...

  9. LinkedList底层代码解析笔记

    LinkedList是属于Sequence List,故遍历是用迭代器更快; LinkedList继承自AbstractSequenceList.实现了List及Deque接口.其实AbstractS ...

  10. python之将Unicode文本标准化

    在需要比较字符串的程序中使用字符的多种表示会产生问题. 为了修正这个问题,你可以使用unicodedata模块先将文本标准化: s1 = 'Spicy Jalape\u00f1o' s2 = 'Spi ...