
WARNING! The remote SSH server rejected X11 forwarding request. Last login: Thu Dec 16 10:53:56 2021 from 192.168.90.101 cd "/usr/local/se901/manager" hahah hahah hahah [root@localhost ~]# cd "/usr/local/" rc.local 文件
#!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot. touch /var/lock/subsys/local echo "hahah" exit 0 看网上没有这方面的坑,不知道大佬有没有遇到过,劳烦指导一下,感激不尽!!!
1 knightdf 2021-12-16 11:06:58 +08:00 为何要加一个:exit 0 ? |
2 ihipop 2021-12-16 11:07:37 +08:00 估计是哪个全局的 profile 或者 shell 的 rc 文件 source 了这个 rc.local 可以 grep/ripgrep 全盘查找一下,如果新建一个用户没这个问题,重点查找用户主目录的那些*rc 文件 |
6 julyclyde 2021-12-16 15:20:00 +08:00 可以看出这机器有很多外行在使用了……唉 |
7 2i2Re2PLMaDnghL 2021-12-16 15:46:06 +08:00 鉴于每个 shell 都是新进程,完全可以把 echo "hahah" 替换成打印进程树(含命令行) |
8 2i2Re2PLMaDnghL 2021-12-16 15:47:36 +08:00 替换成 `pstree -as $$` 就能看到调用树了( |
9 NickYUyu OP @2i2Re2PLMaDnghL 好的 我试试 谢谢 |
11 julyclyde 2021-12-17 12:35:36 +08:00 1 启动后如果不登录,是否会执行三次 2 xshell 窗口执行三次,检查一下 xshell 里面这个 shell 的进程名字开头是否有横线 感觉是某个 profile 文件,用户级、系统级都有可能,里面调用了 rc.local 进一步猜测,你的 rc.local 文件可能没有+x 权限,导致不能正常的自动执行,所以有人为了让他能执行,才添加到 profile 里去了 |
12 EscYezi 2021-12-19 02:45:19 +08:00 via iPhone 一个思路:弄一个环境变量作为标志位,如果检测到环境变量说明被初始化过,直接退出 |
13 julyclyde 2021-12-19 17:52:29 +08:00 @a href="/member/EscYezi">EscYezi 这是掩盖错误的做法 |