1.1 vim /etc/rc.d/rc.local
1.2 chmod +x /etc/rc.d/rc.local
- Ubuntu
见:https://blog.csdn.net/weixin_42096620/article/details/114694640
见: https://www.cnblogs.com/Areas/p/13439000.html
六、配置开机自启动
测试这个方式:
ubuntu中:
cd /etc/init.d
vim rc.local
内容如下
#! /bin/sh
### BEGIN INIT INFO
# Provides: rc.local
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
. /lib/init/vars.sh
. /lib/lsb/init-functions
do_start() {
if [ -x /etc/rc.local ]; then
[ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
/etc/rc.local
ES=$?
[ "$VERBOSE" != no ] && log_end_msg $ES
return $ES
fi
}
case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop|status)
# No-op
exit 0
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
找到vim /etc/rc.local
# fastdfs start
/etc/init.d/fdfs_trackerd start
/etc/init.d/fdfs_storaged start
# nginx start
/usr/local/tengine/sbin/nginx
# keepalived
/usr/local/keepalived/sbin/keepalived
但是这个为什么还是/usr/bin下的fdfs