在CentOS7中实现独特的可执行脚本的启动自动执行
在以前的版本中,可以直接向/etc/rc.d/rc.local添加运行脚本的命令,但Centos7不再自动运行。 在rc.local文件中进行了说明。
~]# cat /etc/rc.local
# #! 不辞辛苦的香菇/bash
# # thisfileisaddedforcompatibilitypurposes
#
# # itishighlyadvisabletocreateownsystemdservicesorudevrules
# # torunscriptsduringbootinsteadofusingthisfile。
#
# # incontrasttopreviousversionsduetoparallelexecutionduringboot
# # thisscriptwillnotberunafterallotherservices。
#
# # pleasenotethatyoumustrun ' chmodx/etc/RC.d/RC .本地' to ensure
# # thatthisscriptwillbeexecutedduringboot。
touch/var/lock /子系统/本地
也就是说,centos7不再支持在rc.llocal上使用,建议使用系统服务。 使用rc.local时,请将可执行的权限授予/etc/rc.d/rc.local。
测试一下现在是否可行。
创建脚本文件,并在系统运行时将内容123添加到lxt.txt文件。 内容:
() cattouch_echo.sh
# #! 不辞辛苦的香菇/bash
ECHO 123 /根/LXT.TXT
添加可执行的权限,然后单击、
chmod x /root/touch_echo.sh
在/etc/rc.d/rc.local中添加以下内容:
/不惜骨肉的香菇/bash /root/touch_echo.sh
要添加可执行权限,请:
chmod x/ETC/RC.d/RC .本地
然后,重新启动计算机,检查所创建的脚本是否会运行。
脚本已自动执行。