解决 rc.local 开机启动 perl 脚本失败

有个脚本需要开机启动,结果 rc.local 老兄非常不给面子,折腾的心力交瘁死活就是不执行.

网上查了很多资料:

/etc/rc.d/rc.local 有执行权限
source /etc/profile 载入环境变量都没有解决问题

但我考虑肯定还是环境变量有问题, ssh 登上来就能执行,咋 rc.local 就不行呢!!!

于是,绝顶聪明的本人想出了一个绝顶聪明的办法... 通过 su -c 自动带入环境变量...

OK, reboot 脚本终于开机启动了 (๑•ᴗ•๑)

#!/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.

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

su -c  /home/app/search/start.pl   #就是这一行(๑•ᴗ•๑)

touch /var/lock/subsys/local
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容