现在的 opensuse 自启动脚本怎么添加的?

不是登录脚本,/etc/rc.local 没用,有没有简单方法?不想注册什么服务

所有发行版都由 systemd 控制,必须写服务没办法,简单方法好像没有。

https://www.redhat.com/sysadmin/replacing-rclocal-systemd

KDE 的话可以用 Autostart

systemctl cat after-local.service

# /usr/lib/systemd/system/after-local.service
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

[Unit]
Description=/etc/init.d/after.local Compatibility
ConditionFileIsExecutable=/etc/init.d/after.local
After=getty.target

[Service]
Type=idle
ExecStart=/etc/init.d/after.local
TimeoutSec=0
RemainAfterExit=yes

/etc/init.d/after.local里面写你要启动的脚本或者把写好的添加到里面就行
下面是我自己的

cat /etc/init.d/after.local

#!/bin/sh

# 脚本依赖于 /usr/lib/systemd/system/after-local.service 运行
echo "$(date):系统已启动..." >> /var/log/after-local.log
# 启用 swap 交换文件
/usr/sbin/swapon /swapfile && /usr/bin/free -m >> /home/xuan/logs/swapfile.log

# /usr/bin/chmod +x /usr/local/sbin/disk-rm-all.sh 
# /usr/local/sbin/disk-rm-all.sh 

这个不行的话就自己写服务了 参考楼上说的 systemd

Cron
@reboot

antiX MX Linux 还在使用 SysV

1赞