Systemd 如何快速建立用户服务

Systemd 现代 Linux 发行版基本都已经切换到此作为系统进程管理. 对于我,好处是带来了用户级别的进程管理. 建立 ~/.config/systemd/user/ 这个目录是用户级服务的存储目录,如果没有则需要新建 mkdir -p ~/.config/systemd/user/ 生成对应的服务 每个服务都对应一个 sample.service 其中 sample 一般是服务缩写 增加描述 Description 好处是在执行 systemctl --user status 可以查看更好 cat << EOF > ~/.config/systemd/user/sample.service [Unit] Description=Sample Service [Service] # 工作目录 # WorkingDirectory=/data/work/path # 启动执行 ExecStart=echo hello world # 总是重启,按照此例子,只会每5秒输出一次 hello world Restart=always RestartSec=5s [Install] WantedBy=default.target EOF 执行服务 必须带有 --user 参数 systemctl --user enable sample # 激活 sample systemctl --user start sample 后话 此处仅是建立了用户的简单服务. 每次重启后, systemd 会启动此服务....

2021/07/25 Jul · 1 min · 71 words · SCys

OpenWRT 国内镜像

国内访问OpenWRT路由器的资源一直都出现问题,镜产用到国内镜像. 配置文件 针对文件 /etc/opkg/distfeeds.conf # 这是 Redmi AX6 的默认配置 #src/gz openwrt_core http://downloads.openwrt.org/releases/18.06-SNAPSHOT/targets/ipq807x_64/MiWiFi/packages #src/gz mi_base http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/aarch64_cortex-a53/base #src/gz mi_packages http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/aarch64_cortex-a53/packages #src/gz mi_routing http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/aarch64_cortex-a53/routing 替换 downloads.openwrt.org 到特定的镜像. 中国科学技术大学开源软件镜像 直替换命令: sed -i s_downloads.openwrt.org_mirrors.ustc.edu.cn/openwrt_g /etc/opkg/distfeeds.conf 清华大学开源软件镜像站 直替换命令: sed -i 's_downloads.openwrt.org_mirrors.tuna.tsinghua.edu.cn/openwrt_' /etc/opkg/distfeeds.conf 不要替换 http:// 为 https:// ,很多项目默认的 wget 是不支持 https,主要是为了省空间

2020/12/04 Dec · 1 min · 44 words · SCys

国内镜像|CN Open Source Mirrors

国内镜像 OpenTUNA开源软件镜像站 中国科学技术大学开源软件镜像 阿里云官方镜像站 腾讯软件源 简单介绍 阿里云和腾讯基本不用介绍,大而全 opentuna 就是 由清华大学 TUNA 协会,辅以由西云数据运营的 AWS 中国(宁夏)区域上正式上线并开放服务

2020/12/03 Dec · 1 min · 14 words · SCys

Docker 的基本配置

Docker 快速配置文件 保存 /etc/docker/deamon.json { "registry-mirrors": [ "https://05f073ad3c0010ea0f4bc00b7105ec20.mirror.swr.myhuaweicloud.com/", "http://hub-mirror.c.163.com/" ], "dns": ["114.114.114.114", "223.5.5.5"], "log-driver": "json-file", "log-opts": { "max-size": "10m", "max-file": "3", "labels": "production_status", "env": "os,customer" } } Docker Hub 的镜像 华为: 定制公开镜像,需要到 华为云 注册建立 从 https://segmentfault.com/a/1190000023117518 抄来的:D https://05f073ad3c0010ea0f4bc00b7105ec20.mirror.swr.myhuaweicloud.com/ 阿里: 定制公开镜像,需要到 阿里云 注册建立 :D 没事其实并不好用,所以就不提供了 如果要用可以使用 http://docker.mirrors.ustc.edu.cn 网易: 公有 http://hub-mirror.c.163.com

2020/11/25 Nov · 1 min · 49 words · SCys

快速修复Grub启动分区

近期遇到错误删除 Grub 启动分区,而引起无法启动的问题. 由于主分区用的是 Btrfs 格式,Grub 就需要将自己一个 core.img 嵌入到一个大小为 2M 左右的分区内. 修复步骤: gdisk 重新建立一个分区,大小为 2M 左右即可 gdisk 修改分区 code 为 EF02 grub-install /dev/SDA (SDA 为系统盘标识符),期间会自动识别 EF02 分区将 core.img 作为嵌入分区. 重启即可 引用: BIOS boot partition BIOS installation #GPT ‘‘EFI boot partition’’ and ‘‘biosgrub’’ partition

2020/10/07 Oct · 1 min · 43 words · SCys