龙空技术网

CentOS7下/etc/rc.local开启自启不执行问题处理

潇洒sword 389

前言:

眼前我们对“centos7开机自动开启rsync”大体比较关切,兄弟们都想要分析一些“centos7开机自动开启rsync”的相关内容。那么小编同时在网摘上搜集了一些有关“centos7开机自动开启rsync””的相关文章,希望大家能喜欢,兄弟们快快来了解一下吧!

1、原因:服务器重启后rsync服务没有起来,rsync启动已经写入/etc/rc.local中

2:分析:查看more /etc/rc.local

写启动内容没问题,也是全路径;查看 /etc/rc.local 文件,是一个链接,链接到 /etc/rc.d/rc.local,查看 /etc/rc.d/rc.local 文件,发现没有执行权限。

[root@master ~]# more /etc/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

/usr/local/sersync/bin/sersync2 -r -d -o /usr/local/sersync/conf/confxml.xml

[root@master ~]#

[root@slave ~]# more /etc/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

rsync --daemon --config=/etc/rsyncd.conf

[root@slave ~]#

3、加上执行权限之后,再重启发现服务自动起来了。

[root@master ~]# chmod +x /etc/rc.d/rc.local

[root@master ~]# ll /etc/rc.d/rc.local

-rwxr-xr-x. 1 root root 527 Aug 17 2022 /etc/rc.d/rc.local

[root@master ~]# reboot

[root@slave ~]# lsof -i:873

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

rsync 888 root 4u IPv4 21280 0t0 TCP *:rsync (LISTEN)

rsync 888 root 5u IPv6 21281 0t0 TCP *:rsync (LISTEN)

[root@slave ~]#

[root@slave ~]# netstat -lntup | grep rsync

tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 888/rsync

tcp6 0 0 :::873 :::* LISTEN 888/rsync

[root@slave ~]#

标签: #centos7开机自动开启rsync