centos配置开机自启动实现过程
作者:冰川_
以上内容主要介绍了使用elasticsearch为例,编写运行脚本、配置执行权限及开机自启动的方法,旨在为读者提供参考
以elasticsearch为例子
写实际运行的脚本
vi /home/iscas/autostart.sh
#!bin/bash su iscas<<! nohup /home/iscas/es/elasticsearch-6.1.3/bin/elasticsearch > /home/iscas/es/elasticsearch-6.1.3/logs/elasticsearch_start.log 2>&1 &
给执行权限
chmod 777 /home/iscas/autostart.sh
配置开机自启动
vi /etc/rc.d/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 sh /home/iscas/autostart.sh
给执行权限
chmod 777 /etc/rc.d/rc.local
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
