失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > Centos设置开机自动启动

Centos设置开机自动启动

时间:2018-11-12 21:26:56

相关推荐

Centos设置开机自动启动

1.编辑/etc/rc.d/下的rc.local文件

如果还没有给与rc.local文件可执行权限,则先执行命令赋予rc.local可执行权限

chmod +x /etc/rc.d/rc.local

2.然后编辑rc.local文件,以在/mnt/why文件夹下执行脚本为例:

#!/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/localcd /mnt/why./monitor.sh >> logfile.log 2>&1

3.如果未执行成功,查看logfile.log日志,如果未找到脚本中的某个命令,但在Xshell又可以执行的话,则在脚本中的命令前加上

source /etc/profile

例如:

#!/bin/bashsource /etc/profilenohup java -jar test.jar &

如果觉得《Centos设置开机自动启动》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。