起因:服務器重啟rsync服務沒有起來,rsync啟動已經寫入/etc/rc.local中
[root@localhost ~]# 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. /usr/bin/rsync --daemon
排查,寫的啟動沒問題,也是全路徑,查看 /etc/rc.local 文件,是一個鏈接,鏈接到 /etc/rc.d/rc.local,查看 /etc/rc.d/rc.local 文件,發現沒有執行權限。
[root@localhost ~]# chmod +x /etc/rc.d/rc.local [root@localhost ~]# ll /etc/rc.d/rc.local -rwxr-xr-x. 1 root root 527 Aug 17 2018 /etc/rc.d/rc.local [root@localhost ~]# reboot
加上執行權限之后,再重啟發現服務自動起來了。
[root@localhost ~]# lsof -i:873 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME rsync 879 root 4u IPv4 18513 0t0 TCP *:rsync (LISTEN) rsync 879 root 5u IPv6 18514 0t0 TCP *:rsync (LISTEN) [root@localhost ~]# netstat -lntup | grep rsync tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 879/rsync tcp6 0 0 :::873 :::* LISTEN 879/rsync [root@localhost ~]#
