首页 > 编程知识 正文

如何设置脚本自动运行(windows设置开机自启动脚本)

时间:2023-05-03 09:54:08 阅读:85948 作者:441

在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 .本地

然后,重新启动计算机,检查所创建的脚本是否会运行。

脚本已自动执行。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。