怎么把java文件夾給傳過去了
rsync +inotify 監控代碼實時傳輸調試
沒看到日志
這里面有了
rsync -e"ssh -p 3712" -av /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/
文件夾后面的/要加上
[root@localhost java]# cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
echo “ ( d a t e + ′ (date + '%F %T') fasheng (date+′events” >>/var/log/rsync.log 2>&1 [root@localhost java]# cat /var/log/rsync.log
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
‘date+%F\ %T’ fasheng/root/app/java/ CREATE 321.java
‘date+%F\ %T’ fasheng/root/app/java/ MODIFY 321.java
‘date+%F\ %T’ fasheng/root/app/java/ CREATE 21.java
‘date+%F\ %T’ fasheng/root/app/java/ ATTRIB 21.java
‘date+%F\ %T’ fasheng/root/app/java/ CREATE 34.txt
‘date+%F\ %T’ fasheng/root/app/java/ ATTRIB 34.txt
‘date+%F\ %T’ fasheng/root/app/java/ CREATE 322.java
‘date+%F\ %T’ fasheng/root/app/java/ MODIFY 322.java
‘date+%F\ %T’ fasheng/root/app/java/ CREATE 333.java
‘date+%F\ %T’ fasheng/root/app/java/ MODIFY 333.java
問題:為什么倒數幾行不顯示傳輸的具體時間 我配置了inotify.sh:主要作用是當監控到源文件夾中文件變化時,將源文件夾中文件同步到目標主機目標文件夾,并使用echo " ( d a t e + ′ (date + '%F %T')" fasheng (date+′events >>/var/log/rsync.log 2>&1
兩個問題:1.修改shell后是否需要重新nohup ./.sh & 看日志沒有同步記錄 2.rsync --delete 同步是以源文件夾為準 進行刪除嗎?
參考
2.是
1.計劃試一下
沒有變化
看上去是同步了 但是日志里沒有記錄
沒監控到?
確實把目標主機的刪了 和源主機的同步了
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -e(ssh -p 3712) -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date +%F\ %T) fasheng$events" >> /var/log/rsync.log 2>&1
done
為什么192.168.235.100:/home/code/backup/java_backup 出現新文件時,/root/app/java沒有同步刪除 /home/code/backup/java_backup中的文件,日志中沒有監控記錄
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
沒看到變化
為啥沒同步過去
要有免密登錄才能實時傳嗎
免密登錄
手動能傳過去
為什么不能監控備份呢
計劃刪掉輸出到日志文件看下
不能監控備份 是因為inotifywait 失效嗎
[caozx26@code java]$ cd /home/caozx26
[caozx26@code ~]$ ls
app 公共 模板 視頻 圖片 文檔 下載 音樂 桌面
[caozx26@code ~]$
#code是什么意思
code是什么意思,我現在不在code目錄下 @前后表達的含義
確實 我的inotify.sh在/usr/local/bin/目錄下,在其他目錄直接執行nohup ./inotify.sh &能順利運行該進程嗎?&是什么意思
根據你的問題,以下是詳細解答:
一、能否在其他目錄直接運行 nohup ./inotify.sh &? ??答案:不能直接運行??。原因如下:
??路徑問題??:./inotify.sh 表示執行當前目錄下的 inotify.sh 腳本。如果你的腳本實際位于
/usr/local/bin/ 目錄,且當前工作目錄不在 /usr/local/bin,則系統會提示找不到文件。 ??正確執行方式??:
??使用絕對路徑??:nohup /usr/local/bin/inotify.sh &。 ??利用 PATH 環境變量??:若
/usr/local/bin 已加入系統 PATH,可直接通過腳本名執行:nohup inotify.sh &。 二、& 符號的作用 & 是
Linux 中用于將命令放入后臺運行的符號,具體功能包括:??后臺執行??:命令不會阻塞終端,用戶可繼續輸入其他操作。 ??輸出控制??:
默認情況下,后臺進程的輸出會顯示在終端(可能干擾當前操作)。 建議結合輸出重定向(如 > output.log 2>&1)避免輸出混亂。
??進程管理??: 通過 jobs 查看后臺任務列表,fg %n 將任務帶回前臺,kill %n 終止任務。 若未使用
nohup,終端關閉后后臺任務會被終止(因收到 SIGHUP 信號)。
若intofy.sh在/usr/local/bin目錄下,進入/usr/local/bin,然后直接運行nohup ./inotify.sh & 可以嗎?如果成功運行了,inotify.sh中的內容是否就可以一直執行了
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
不是已經指定了端口訪問 為什么nohup.out 還是報錯 port22
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -e"ssh -p 3712" -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date +%F\ %T) fasheng$events" >> /var/log/rsync.log 2>&1
done
[root@localhost bin]# rsync -e “ssh -p 3712” -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/
sending incremental file list
deleting 34.txt
./
sent 476 bytes received 39 bytes 1,030.00 bytes/sec
total size is 6,291,456 speedup is 12,216.42
單獨執行rsync語句有用,為什么一放到inotify.sh腳本文件中就不執行。/var/log/rsync.log記錄了刪除記錄。nohup.out中都是錯誤記錄:ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
[root@localhost bin]#
[root@localhost bin]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
do
rsync -e “ssh -p 3712” -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/
echo “ ( d a t e + (date +%F\ %T) fasheng (date+events” >> /var/log/rsync.log 2>&1
done
改回來報錯
b把默認端口改為22試試
ssh code@192.168.235.100
ssh: connect to host 192.168.235.100 port 22: Connection refused
a
[root@localhost bin]# vim /usr/local/bin/inotify.sh
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date +%F\ %T) fasheng$events" >> /var/log/rsync.log 2>&1
done [root@localhost bin]# cd /root/app/java
您在 /var/spool/mail/root 中有郵件
[root@localhost java]# ls
66.java 69.java aa3 file20.java file23.java file4.java file7.java
67.java aa1 file19.java file21.java file2.java file5.java
68.java aa2 file1.java file22.java file3.java file6.java
[root@localhost java]# rm -rf 66.java
[root@localhost java]# ls
67.java 69.java aa2 file19.java file20.java file22.java file2.java file4.java file6.java
68.java aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
[root@localhost java]# cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 21.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 321.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 322.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 333.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 34.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 35.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 66.java
[root@localhost java]# ls
67.java 69.java aa2 file19.java file20.java file22.java file2.java file4.java file6.java
68.java aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
您在 /var/spool/mail/root 中有郵件
[root@localhost java]# rm -rf 67.java
[root@localhost java]# ls
68.java aa2 file1.java file22.java file3.java file6.java
69.java aa3 file20.java file23.java file4.java file7.java
aa1 file19.java file21.java file2.java file5.java
[root@localhost java]#
b:
[root@localhost bin]# vim /usr/local/bin/inotify.sh
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date +%F\ %T) fasheng$events" >> /var/log/rsync.log 2>&1
done [root@localhost bin]# cd /root/app/java
您在 /var/spool/mail/root 中有郵件
[root@localhost java]# ls
66.java 69.java aa3 file20.java file23.java file4.java file7.java
67.java aa1 file19.java file21.java file2.java file5.java
68.java aa2 file1.java file22.java file3.java file6.java
[root@localhost java]# rm -rf 66.java
[root@localhost java]# ls
67.java 69.java aa2 file19.java file20.java file22.java file2.java file4.java file6.java
68.java aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
[root@localhost java]# cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 21.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 321.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 322.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 333.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 34.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 35.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 66.java
[root@localhost java]# ls
67.java 69.java aa2 file19.java file20.java file22.java file2.java file4.java file6.java
68.java aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
您在 /var/spool/mail/root 中有郵件
[root@localhost java]# rm -rf 67.java
[root@localhost java]# ls
68.java aa2 file1.java file22.java file3.java file6.java
69.java aa3 file20.java file23.java file4.java file7.java
aa1 file19.java file21.java file2.java file5.java
[root@localhost java]#
現在同步成功了
推測應該是port 的問題
a:
[root@localhost java]# cd /usr/local/bin
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# ls
inotify.sh inotifywait inotifywatch nohup.out
[root@localhost bin]# cat nohup.out
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
./inotify.sh:行4: 未預期的符號 `(' 附近有語法錯誤
./inotify.sh:行4: ` rsync -e(ssh -p 3712) -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup'
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
sending incremental file list
deleting 66.java
deleting 35.txt
./sent 437 bytes received 50 bytes 324.67 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
deleting 67.java
./sent 418 bytes received 40 bytes 916.00 bytes/sec
total size is 0 speedup is 0.00
查看nohup可以看到成功同步了
推測之前的應該是端口無法在shell中識別
之前配置過
/usr/local/bin/inotifywait -mrq -e create,move,delete,attrib,modify /root/app/java |while read events
dorsync -e"ssh -p 3712" -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup
#echo"'date + %F\ %T' SHIJIAN$events">>/var/log/rsync.log 本句語法推測有點問題 rsync.log中時間不能顯示 故注掉
done
還配置過
rsync -e"/usr/bin/ssh -p 3712" -av --delete / @ :
這種形式 也沒同步成功
計劃再嘗試下吧 看看能不能同步成功
cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 21.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 321.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 322.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 333.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 34.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 35.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 66.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE aa4
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa4
'date+%F\ %T' fasheng/root/app/java/ CREATE aa5
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa5
'date+%F\ %T' fasheng/root/app/java/ DELETE 68.java
[root@code java]# cat /usr/local/bin/inotfy.sh
cat: /usr/local/bin/inotfy.sh: 沒有那個文件或目錄
[root@code java]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "'date +%F\ %T' fasheng$events" >> /var/log/rsync.log 2>&1
done
為什么/var/log/rsync.log中沒有呈現具體的時間,‘date+%F\ %T’ fasheng/root/app/java/ DELETE 68.java
之前改過
echo “ ( d a t e + (date +%F\ %T) fas (date+events”>>/var/log/rsync.log 2>&1這種形式,/var/log/rsync.log中也沒有呈現具體的時間
[root@code java]# rm -rf 69.java
[root@code java]# cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 21.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 321.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 322.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 333.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 34.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 35.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 66.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE aa4
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa4
'date+%F\ %T' fasheng/root/app/java/ CREATE aa5
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa5
'date+%F\ %T' fasheng/root/app/java/ DELETE 68.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 69.java
[root@code java]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 35 4月 19 17:20 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai[root@code java]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date '+%F %T') fasheng$events" >> /var/log/rsync.log 2>&1
done
修改了后還是/var/log/rsync.log中還是不輸出時間
a:
[root@code java]# pkill -f inotify.sh
[root@code java]# /usr/local/bin/inotify/sh &
[1] 37918
[root@code java]# bash: /usr/local/bin/inotify/sh: 沒有那個文件或目錄
^C
[1]+ 退出 127 /usr/local/bin/inotify/sh
[root@code java]# /usr/local/inotify.sh &
[1] 37968
[root@code java]# bash: /usr/local/inotify.sh: 沒有那個文件或目錄
^C
[1]+ 退出 127 /usr/local/inotify.sh
[root@code java]# /usr/local/bin/inotify.sh &
[1] 37984
[root@code java]# chmod +x /usr/local/bin/inotify.sh &
[2] 38016
[root@code java]# jobs
[1]- 運行中 /usr/local/bin/inotify.sh &
[2]+ 完成 chmod +x /usr/local/bin/inotify.sh
[root@code java]# vim /usr/local/bin/inotify.sh[root@code java]# cat /usr/local/bin/inotify.sh
#!/bin/bash
export TZ=Asia/Shanghai
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date '+%F %T') fasheng$events" >> /var/log/rsync.log 2>&1
done [root@code java]# touch /root/java/testfile
touch: 無法創建"/root/java/testfile": 沒有那個文件或目錄
[root@code java]# touch /root/app/java/testfile
[root@code java]# sending incremental file list
./
testfilesent 472 bytes received 48 bytes 346.67 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 426 bytes received 22 bytes 896.00 bytes/sec
total size is 0 speedup is 0.00
^C
[root@code java]# jobs
[1]+ 運行中 /usr/local/bin/inotify.sh &
[root@code java]# tail -n 5 /var/log/rsync.log
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa5
'date+%F\ %T' fasheng/root/app/java/ DELETE 68.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 69.java
2025-05-24 19:42:29 fasheng/root/app/java/ CREATE testfile
2025-05-24 19:42:29 fasheng/root/app/java/ ATTRIB testfile
可以了
問題1不顯示時間解決了,推測是格式問題
[root@code bin]# vim /usr/local/bin/inotify.sh
[root@code bin]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date '+%F %T') fasheng$events" >> /var/log/rsync.log 2>&1
done [root@code bin]# pkill -f inotify.sh
[1]+ 已終止 nohup ./inotify.sh
[root@code bin]# nohup ./inotify.sh &
[1] 42179
[root@code bin]# nohup: 忽略輸入并把輸出追加到"nohup.out"
jobs
[1]+ 運行中 nohup ./inotify.sh &
[root@code bin]# touch /root/app/java/testfile8.java
[root@code bin]# tail -5 /var/log/rsync.log
2025-05-24 19:43:47 fasheng/root/app/java/ ATTRIB testfile2
2025-05-24 20:03:44 fasheng/root/app/java/ CREATE testfile4.java
2025-05-24 20:03:45 fasheng/root/app/java/ ATTRIB testfile4.java
2025-05-24 20:24:51 fasheng/root/app/java/ CREATE testfile8.java
2025-05-24 20:24:51 fasheng/root/app/java/ ATTRIB testfile8.java
格式問題
推測端口問題也應該要先殺死進程 再重新啟動
[root@code app]# cd java
bash: cd: java: 不是目錄
[root@code app]# mkdir /java
[root@code app]# ;s
bash: 未預期的符號 `;' 附近有語法錯誤
[root@code app]# ls
java
[root@code app]# cd java
bash: cd: java: 不是目錄
[root@code app]# mkdir /java
mkdir: 無法創建目錄"/java": 文件已存在
[root@code app]# ls
java
[root@code app]# cd java
bash: cd: java: 不是目錄
[root@code bin]# rm -rf /root/app/java testfile2
[root@code bin]# tail -5 /var/log/rsync.log
2025-05-24 20:26:25 fasheng/root/app/java/ DELETE testfile2
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE nohup.out
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE testfile4.java
2025-05-24 20:26:27 fasheng/root/app/java/ DELETE testfile8.java
2025-05-24 20:26:27 fasheng/root/app/java/ IGNORED
[root@code bin]# ls /root/app/java
ls: 無法訪問/root/app/java: 沒有那個文件或目錄
[root@code bin]# cd /root/app/java
[root@code app]# cd ./java
[root@code java]# touch {1..4}.java
[root@code java]# ls
1.java 2.java 3.java 4.java
[root@code java]# tail -5 /var/log/rsync.log
2025-05-24 20:26:25 fasheng/root/app/java/ DELETE testfile2
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE nohup.out
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE testfile4.java
2025-05-24 20:26:27 fasheng/root/app/java/ DELETE testfile8.java
2025-05-24 20:26:27 fasheng/root/app/java/ IGNORED
[root@code java]# jobs
[1]+ 運行中 nohup ./inotify.sh &(工作目錄:/usr/local/bin)
[root@code java]# tail -5 /usr/local/bin/nohup.out
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
a:
[root@code java]# touch 5.java
[root@code java]# tail -5 /var/log/rsync.log\
> ^C
[root@code java]#
[root@code java]# tail -5 /var/log/rsync.log
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE testfile4.java
2025-05-24 20:26:27 fasheng/root/app/java/ DELETE testfile8.java
2025-05-24 20:26:27 fasheng/root/app/java/ IGNORED
2025-05-24 21:11:50 fasheng/root/app/java/ CREATE 5.java
2025-05-24 21:11:50 fasheng/root/app/java/ ATTRIB 5.java
[root@code java]# tail -5 /usr/local/bin/nohup.out
total size is 0 speedup is 0.00
sending incremental file listsent 141 bytes received 12 bytes 306.00 bytes/sec
total size is 0 speedup is 0.00
[root@code java]# tail -10 /usr/local/bin/nohup.out
sending incremental file list
./
5.javasent 187 bytes received 38 bytes 150.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 141 bytes received 12 bytes 306.00 bytes/sec
total size is 0 speedup is 0.00
b
復制粘貼到外部環境又失效了b 虛擬機內粘貼了也不行 出來還是粘貼的a的代碼
又好了
b
測試成功
若改變shell內容:指定端口 需先斷開 再連接
源碼
節點a:
[caozx26@code dir1]$ date
2025年 05月 24日 星期六 13:18:31 CST
[caozx26@code dir1]$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.235.254 0.0.0.0 UG 0 0 0 ens33
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 ens33
192.168.235.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
[caozx26@code dir1]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:d6:84:b3 brd ff:ff:ff:ff:ff:ffinet 192.168.235.10/24 brd 192.168.235.255 scope global ens33valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:fed6:84b3/64 scope link valid_lft forever preferred_lft forever
3: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000link/ether 52:54:00:d1:59:30 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000link/ether 52:54:00:d1:59:30 brd ff:ff:ff:ff:ff:ff
[caozx26@code dir1]$ ping 192.168.235.100
PING 192.168.235.100 (192.168.235.100) 56(84) bytes of data.
64 bytes from 192.168.235.100: icmp_seq=1 ttl=64 time=1.50 ms
64 bytes from 192.168.235.100: icmp_seq=2 ttl=64 time=2.64 ms
64 bytes from 192.168.235.100: icmp_seq=3 ttl=64 time=2.84 ms
^C
--- 192.168.235.100 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2007ms
rtt min/avg/max/mdev = 1.502/2.330/2.843/0.592 ms
[caozx26@code dir1]$ ssh root@192.168.235.100
The authenticity of host '192.168.235.100 (192.168.235.100)' can't be established.
ECDSA key fingerprint is SHA256:PbCAj5CjyP8yLyHMKdEPFFA4planWCr8FpxrrOp3d+I.
ECDSA key fingerprint is MD5:5b:0a:38:81:36:32:b6:38:d1:d8:3b:61:12:39:5a:fc.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': y
Please type 'yes' or 'no': yes
Warning: Permanently added '192.168.235.100' (ECDSA) to the list of known hosts.
root@192.168.235.100's password:
Permission denied, please try again.
root@192.168.235.100's password:
Last failed login: Sat May 24 13:21:23 CST 2025 from 192.168.235.10 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Sat May 24 13:19:55 2025
[root@backup ~]# exit
登出
Connection to 192.168.235.100 closed.
[caozx26@code dir1]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/caozx26/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/caozx26/.ssh/id_rsa.
Your public key has been saved in /home/caozx26/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:/s621fa7t7h6+fwi9z13I6Uo0jasH0ZlebLNJcpeDCI caozx26@code.itcast.cn
The key's randomart image is:
+---[RSA 2048]----+
| |
| . |
| E . * o . |
| . = X o |
| S. + = |
| .. . .. . |
| +o .o * |
| ..Ooo.*=+=|
| .=+Boo=+O/|
+----[SHA256]-----+
[caozx26@code dir1]$ ssh-copy-id root@192.168.235.100
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/caozx26/.ssh/id_rsa.pub"
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.235.100's password: Number of key(s) added: 1Now try logging into the machine, with: "ssh 'root@192.168.235.100'"
and check to make sure that only the key(s) you wanted were added.[caozx26@code dir1]$ ssh root@192.168.235.100
Last login: Sat May 24 13:21:28 2025 from 192.168.235.10
[root@backup ~]# exit
登出
Connection to 192.168.235.100 closed.
[caozx26@code dir1]$ //mian mi denglu chenggong,jihua pei rsync jiankong
-bash: //mian: 沒有那個文件或目錄
[caozx26@code dir1]$ cd
[caozx26@code ~]$ ls
公共 模板 視頻 圖片 文檔 下載 音樂 桌面
[caozx26@code ~]$ ld /
/: 文件無法辨識: 是一個目錄
[caozx26@code ~]$ ls /
app boot dir1 dir12 dir2 etc lib media opt root sbin srv tmp var
bin dev dir11 dir13 dir3 home lib64 mnt proc run shop sys usr
[caozx26@code ~]$ cd /app
[caozx26@code app]$ ls
java_project
[caozx26@code app]$ cd /usr/local
[caozx26@code local]$ ls
bin etc games include inotify-tools-3.13 lib lib64 libexec sbin share src
[caozx26@code local]$ cd bin
[caozx26@code bin]$ ls
inotifywait inotifywatch
[caozx26@code bin]$ 2.bianxie bash
bash: 2.bianxie: 未找到命令...
[caozx26@code bin]$ 2.bianxie shell
bash: 2.bianxie: 未找到命令...
[caozx26@code bin]$ huibuhui shi meizhaodao mulu
bash: huibuhui: 未找到命令...
[caozx26@code bin]$ cd /
[caozx26@code /]$ ls
app boot dir1 dir12 dir2 etc lib media opt root sbin srv tmp var
bin dev dir11 dir13 dir3 home lib64 mnt proc run shop sys usr
[caozx26@code /]$ vim inotify.sh
[caozx26@code /]$ dao di shiyong root yonghu haishi yong qita honghu ,qi ru zai shiji huanjing zhong ,bukeneng douyong root yonghu ba
bash: dao: 未找到命令...
[caozx26@code /]$ xian ce yi xia rsync
bash: xian: 未找到命令...
[caozx26@code /]$ ll app
總用量 0
drwxr-xr-x. 5 root root 215 5月 15 21:30 java_project
[caozx26@code /]$ cd /app/java_project
[caozx26@code java_project]$ ls
2.java aa2 file1.java file3.java file5.java file7.java file9.java
aa1 aa3 file2.java file4.java file6.java file8.java
[caozx26@code java_project]$ touch {10..13}.java
touch: 無法創建"10.java": 權限不夠
touch: 無法創建"11.java": 權限不夠
touch: 無法創建"12.java": 權限不夠
touch: 無法創建"13.java": 權限不夠
[caozx26@code java_project]$ mkdir -p /home/caozx26/app/java
[caozx26@code java_project]$ cd /home/caozx26
[caozx26@code ~]$ cd app
[caozx26@code app]$ ls
java
[caozx26@code app]$ cd java
[caozx26@code java]$ cai xiang zai shiji shengchanzhong ,yige yonghu yige zhanghao ,huo tongyi zhanghao ,xiangguan daima wenjianjia peizhihao quanxian
bash: cai: 未找到命令...
[caozx26@code java]$ touch {1..6}.java
[caozx26@code java]$ ls
1.java 2.java 3.java 4.java 5.java 6.java
[caozx26@code java]$ rsync /home/caozx26/app/java/ root@192.168.235.100:/backup/app1_java
skipping directory .
[caozx26@code java]$ rsync -av /home/caozx26/app/java root@192.168.235.100:/backup/app1_java
sending incremental file list
java/
java/1.java
java/2.java
java/3.java
java/4.java
java/5.java
java/6.javasent 423 bytes received 134 bytes 371.33 bytes/sec
total size is 0 speedup is 0.00
[caozx26@code java]$ ls
1.java 2.java 3.java 4.java 5.java 6.java
[caozx26@code java]$ rsync -av /home/caozx26/app/java/ root@192.168.235.100:/backup/app1_java
sending incremental file list
./
1.java
2.java
3.java
4.java
5.java
6.javasent 405 bytes received 15,211 bytes 10,410.67 bytes/sec
total size is 0 speedup is 0.00
[caozx26@code java]$ rsync -av --delete /home/caozx26/app/java/ root@192.168.235.100:/backup/app1_java
sending incremental file list
deleting java/6.java
deleting java/5.java
deleting java/4.java
deleting java/3.java
deleting java/2.java
deleting java/1.java
deleting java/
deleting aa3/
deleting aa2/
deleting aa1/
deleting file9.java
deleting file8.java
deleting file7.java
deleting file6.java
deleting file5.java
deleting file4.java
deleting file3.java
deleting file2.java
deleting file1.javasent 168 bytes received 261 bytes 286.00 bytes/sec
total size is 0 speedup is 0.00
[caozx26@code java]$ cd /home/code
-bash: cd: /home/code: 權限不夠
[caozx26@code java]$ cd /home/caozx26
[caozx26@code ~]$ ls
app 公共 模板 視頻 圖片 文檔 下載 音樂 桌面
[caozx26@code ~]$ ll -d /etc
drwxr-xr-x. 145 root root 8192 5月 24 13:17 /etc
[caozx26@code ~]$ ls
app 公共 模板 視頻 圖片 文檔 下載 音樂 桌面
[caozx26@code ~]$ cd /home/caozx26
[caozx26@code ~]$ ls
app 公共 模板 視頻 圖片 文檔 下載 音樂 桌面
[caozx26@code ~]$ hostname
code.itcast.cn
[caozx26@code ~]$ ls
app 公共 模板 視頻 圖片 文檔 下載 音樂 桌面
[caozx26@code ~]$ cd app
[caozx26@code app]$ ls
java
[caozx26@code app]$ ll -d /usr
drwxr-xr-x. 13 root root 155 4月 17 05:01 /usr
[caozx26@code app]$ cd ~
[caozx26@code ~]$ ls
app 公共 模板 視頻 圖片 文檔 下載 音樂 桌面
[caozx26@code ~]$ vim inotify.sh
[caozx26@code ~]$ cat inotify.sh
/usr/lcoal/bin/inotifywait -mrq -e create,modify,move,delete,attrib /home/caozx26
[caozx26@code ~]$ cd /usr/local/bin
[caozx26@code bin]$ cd inotifywait
-bash: cd: inotifywait: 不是目錄
[caozx26@code bin]$ ls
inotifywait inotifywatch
[caozx26@code bin]$ inotifywait -mrq -e create,modify,move,delete,attrib /home/caozx26/app/java
^C
[caozx26@code bin]$ cd /home/caox26/
-bash: cd: /home/caox26/: 沒有那個文件或目錄
[caozx26@code bin]$ cd /home
[caozx26@code home]$ cd caozx26
[caozx26@code ~]$ cd -
/home
[caozx26@code home]$ cd -
/home/caozx26
[caozx26@code ~]$ ls
app inotify.sh 公共 模板 視頻 圖片 文檔 下載 音樂 桌面
[caozx26@code ~]$ vim inotify.sh
[caozx26@code ~]$ chmod +X inotify.sh
[caozx26@code ~]$ cat inotify.sh
/usr/lcoal/bin/inotifywait -mrq -e create,modify,move,delete,attrib /home/caozx26/app/java |while read events
dorsync -av /home/caozx26/app/java/ root@192.168.235.100:/backup/app1_javadone
[caozx26@code ~]$
節點b
[backup@backup ~]$ date
2025年 05月 24日 星期六 13:18:24 CST
[backup@backup ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:04:f5:98 brd ff:ff:ff:ff:ff:ffinet 192.168.235.100/24 brd 192.168.235.255 scope global ens33valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:fe04:f598/64 scope link valid_lft forever preferred_lft forever
3: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000link/ether 52:54:00:53:dd:1d brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000link/ether 52:54:00:53:dd:1d brd ff:ff:ff:ff:ff:ff
[backup@backup ~]$ cd /etc/sshd
-bash: cd: /etc/sshd: 沒有那個文件或目錄
[backup@backup ~]$ cd /etc/ssh
[backup@backup ssh]$ cat sshd_config
cat: sshd_config: 權限不夠
[backup@backup ssh]$ su - caozx26
密碼:
上一次登錄:六 5月 17 17:37:50 CST 2025pts/2 上
[caozx26@backup ~]$ sudo su
[sudo] caozx26 的密碼:
[root@backup caozx26]# cat sshd_config
cat: sshd_config: 沒有那個文件或目錄
[root@backup caozx26]# cat /etc/ssh/sshd_config
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.# This sshd was compiled with PATH=/usr/local/bin:/usr/bin# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key# Ciphers and keying
#RekeyLimit default none# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO# Authentication:#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10#PubkeyAuthentication yes# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys#AuthorizedPrincipalsFile none#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none# no default banner path
#Banner none# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
[root@backup caozx26]# ls
公共 模板 視頻 圖片 文檔 下載 音樂 桌面
[root@backup caozx26]# ls backup
ls: 無法訪問backup: 沒有那個文件或目錄
[root@backup caozx26]# cd /root/backup
bash: cd: /root/backup: 沒有那個文件或目錄
[root@backup caozx26]# ls /
2010 bin dev home lib64 mnt proc run srv tmp var
backup boot etc lib media opt root sbin sys usr
[root@backup caozx26]# cd /backup
[root@backup backup]# ls
app1_java
[root@backup backup]# cd app1_java
[root@backup app1_java]# ls
2.java aa2 file1.java file3.java file5.java file7.java file9.java
aa1 aa3 file2.java file4.java file6.java file8.java
[root@backup app1_java]# ls
2.java aa2 file1.java file3.java file5.java file7.java file9.java
aa1 aa3 file2.java file4.java file6.java file8.java java
[root@backup app1_java]# ls
1.java 3.java 5.java aa1 aa3 file2.java file4.java file6.java file8.java java
2.java 4.java 6.java aa2 file1.java file3.java file5.java file7.java file9.java
[root@backup app1_java]# ls
1.java 2.java 3.java 4.java 5.java 6.java
[root@backup app1_java]#
a:
p6P�
[root@localhost bin]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -e "/usr/bin/ssh -p 3712" -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date +%F\ %T) fasheng$events" >> /var/log/rsync.log 2>&1
done 您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 21.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 321.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 322.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 333.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 34.txt
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# cd /root/app/java
[root@localhost java]# ls
35.txt 67.java 69.java aa2 file19.java file20.java file22.java file2.java file4.java file6.java
66.java 68.java aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
[root@localhost java]# rm -rf 35.txt
[root@localhost java]# ks
bash: ks: 未找到命令...
[root@localhost java]# ls
66.java 69.java aa3 file20.java file23.java file4.java file7.java
67.java aa1 file19.java file21.java file2.java file5.java
68.java aa2 file1.java file22.java file3.java file6.java
[root@localhost java]# cat /var/log/reync.log
cat: /var/log/reync.log: 沒有那個文件或目錄
[root@localhost java]# cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 21.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 321.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 322.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 333.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 34.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 35.txt
您在 /var/spool/mail/root 中有郵件
[root@localhost java]# cd /usr/local/bin
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# ls
inotify.sh inotifywait inotifywatch nohup.out
[root@localhost bin]# cat nohup.out
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
./inotify.sh:行4: 未預期的符號 `(' 附近有語法錯誤
./inotify.sh:行4: ` rsync -e(ssh -p 3712) -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup'
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
[root@localhost bin]# rsync -av /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# ssh code@192.168.235.100
ssh: connect to host 192.168.235.100 port 22: Connection refused
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# ssh code@192.168.235.100
ssh: connect to host 192.168.235.100 port 22: Connection refused
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# ssh code@192.168.235.100
ssh: connect to host 192.168.235.100 port 22: Connection refused
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# ssh code@192.168.235.100
ssh: connect to host 192.168.235.100 port 22: Connection refused
[root@localhost bin]# ping 192.168.235.100
PING 192.168.235.100 (192.168.235.100) 56(84) bytes of data.
64 bytes from 192.168.235.100: icmp_seq=1 ttl=64 time=0.323 ms
64 bytes from 192.168.235.100: icmp_seq=2 ttl=64 time=0.423 ms
^C
--- 192.168.235.100 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.323/0.373/0.423/0.050 ms
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:97:84:5e brd ff:ff:ff:ff:ff:ffinet 192.168.235.20/24 brd 192.168.235.255 scope global ens33valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:fe97:845e/64 scope link valid_lft forever preferred_lft forever
3: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000link/ether 52:54:00:2a:35:da brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000link/ether 52:54:00:2a:35:da brd ff:ff:ff:ff:ff:ff
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# ssh code@192.168.235.100
Last login: Sat May 24 15:53:31 2025 from 192.168.235.20
[code@code ~]$ rsync /root/app/java code@192.168.235.20:/home/code/backup/java_backup
The authenticity of host '192.168.235.20 (192.168.235.20)' can't be established.
ECDSA key fingerprint is SHA256:RBwUidqa/j7LBfrU3DT4o2bFpnk0zY+aWnLFebYwM8I.
ECDSA key fingerprint is MD5:0b:79:2e:7e:10:00:a6:07:74:f8:66:ee:3e:11:61:c8.
Are you sure you want to continue connecting (yes/no)? ^Crsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.2]
[code@code ~]$ rsync -av /root/app/java code@192.168.235.100:/home/code/backup/java_backup
The authenticity of host '192.168.235.100 (192.168.235.100)' can't be established.
ECDSA key fingerprint is SHA256:+8RG4GdpTOwlDCCFt0rsKQV5kuZ3v4pWCO/z9qTTqhw.
ECDSA key fingerprint is MD5:e4:f1:b2:d5:1d:87:e6:2a:6a:0d:ef:27:4f:16:8b:df.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '192.168.235.100' (ECDSA) to the list of known hosts.
code@192.168.235.100's password:
sending incremental file list
rsync: change_dir "/root/app" failed: Permission denied (13)sent 20 bytes received 12 bytes 1.49 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
[code@code ~]$ ^C
[code@code ~]$ exit
登出
Connection to 192.168.235.100 closed.
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# rsync -av /root/app/java code@192.168.235.100:/home/code/bakcup/java_backup
sending incremental file list
rsync: mkdir "/home/code/bakcup/java_backup" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(657) [Receiver=3.1.2]
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# rsync -av /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup
sending incremental file list
./sent 451 bytes received 29 bytes 960.00 bytes/sec
total size is 0 speedup is 0.00
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# vim /usr/local/bin/rsync.sh
[root@localhost bin]# vim /usr/local/bin/inotify.sh
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date +%F\ %T) fasheng$events" >> /var/log/rsync.log 2>&1
done [root@localhost bin]# cd /root/app/java
您在 /var/spool/mail/root 中有郵件
[root@localhost java]# ls
66.java 69.java aa3 file20.java file23.java file4.java file7.java
67.java aa1 file19.java file21.java file2.java file5.java
68.java aa2 file1.java file22.java file3.java file6.java
[root@localhost java]# rm -rf 66.java
[root@localhost java]# ls
67.java 69.java aa2 file19.java file20.java file22.java file2.java file4.java file6.java
68.java aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
[root@localhost java]# cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 21.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 321.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 322.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 333.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 34.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 35.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 66.java
[root@localhost java]# ls
67.java 69.java aa2 file19.java file20.java file22.java file2.java file4.java file6.java
68.java aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
您在 /var/spool/mail/root 中有郵件
[root@localhost java]# rm -rf 67.java
[root@localhost java]# ls
68.java aa2 file1.java file22.java file3.java file6.java
69.java aa3 file20.java file23.java file4.java file7.java
aa1 file19.java file21.java file2.java file5.java
[root@localhost java]# cd /usr/local/bin
您在 /var/spool/mail/root 中有郵件
[root@localhost bin]# ls
inotify.sh inotifywait inotifywatch nohup.out
[root@localhost bin]# cat nohup.out
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
./inotify.sh:行4: 未預期的符號 `(' 附近有語法錯誤
./inotify.sh:行4: ` rsync -e(ssh -p 3712) -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup'
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
sending incremental file list
deleting 66.java
deleting 35.txt
./sent 437 bytes received 50 bytes 324.67 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
deleting 67.java
./sent 418 bytes received 40 bytes 916.00 bytes/sec
total size is 0 speedup is 0.00
[root@localhost bin]# cd /root/app/java
您在 /var/spool/mail/root 中有郵件
[root@localhost java]# ls
68.java 69.java aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@localhost java]# touch aa{4..5}
[root@localhost java]# ls
68.java 69.java aa1 aa2 aa3 aa4 aa5 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@localhost java]# 登出
[caozx26@localhost /]$ cd -
/shop
[caozx26@localhost shop]$ cd -
/
[caozx26@localhost /]$ sudo su
[sudo] caozx26 的密碼:
[root@code /]# cd -
bash: cd: OLDPWD 未設定
[root@code /]# cat /usr/bin/local/nohup.out
cat: /usr/bin/local/nohup.out: 沒有那個文件或目錄
[root@code /]# cat /usr/local/bin/nohup.out
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
./inotify.sh:行4: 未預期的符號 `(' 附近有語法錯誤
./inotify.sh:行4: ` rsync -e(ssh -p 3712) -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup'
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
sending incremental file list
deleting 66.java
deleting 35.txt
./sent 437 bytes received 50 bytes 324.67 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
deleting 67.java
./sent 418 bytes received 40 bytes 916.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
./
aa4
aa5sent 528 bytes received 67 bytes 396.67 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 443 bytes received 22 bytes 930.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 443 bytes received 22 bytes 930.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 443 bytes received 22 bytes 310.00 bytes/sec
total size is 0 speedup is 0.00
[root@code /]# cd /usr/local/bin
[root@code bin]# ls
inotify.sh inotifywait inotifywatch nohup.out
[root@code bin]# cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 21.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 321.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 322.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 333.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 34.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 35.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 66.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE aa4
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa4
'date+%F\ %T' fasheng/root/app/java/ CREATE aa5
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa5
[root@code bin]# vim inotify.sh
[root@code bin]# cat inotift.sh
cat: inotift.sh: 沒有那個文件或目錄
[root@code bin]# cat inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "'date +%F\ %T' fasheng$events" >> /var/log/rsync.log 2>&1
done [root@code bin]# cd /root/app/java
[root@code java]# ls
68.java 69.java aa1 aa2 aa3 aa4 aa5 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@code java]# rm -rf 68.java
[root@code java]# cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 21.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 321.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 322.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 333.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 34.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 35.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 66.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE aa4
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa4
'date+%F\ %T' fasheng/root/app/java/ CREATE aa5
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa5
'date+%F\ %T' fasheng/root/app/java/ DELETE 68.java
[root@code java]# cat /usr/local/bin/inotfy.sh
cat: /usr/local/bin/inotfy.sh: 沒有那個文件或目錄
[root@code java]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "'date +%F\ %T' fasheng$events" >> /var/log/rsync.log 2>&1
done [root@code java]# vim /usr/local/bin/inotify.sh
[root@code java]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date '+%F %T') fasheng$events" >> /var/log/rsync.log 2>&1
done [root@code java]# ls
69.java aa2 aa4 file19.java file20.java file22.java file2.java file4.java file6.java
aa1 aa3 aa5 file1.java file21.java file23.java file3.java file5.java file7.java
[root@code java]# rm -rf 69.java
[root@code java]# cat /var/log/rsync.log
2025/05/20 19:55:49 [39497] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 19:57:15 [39652] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 20:04:57 [40396] rsync: chroot /~/app/java failed: No such file or directory (2)
2025/05/20 13:14:43 [44477] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:14:43 [44477] building file list
2025/05/20 13:14:43 [44477] sent 318 bytes received 72 bytes total size 0
2025/05/20 13:40:01 [46901] rsync on app/ from UNKNOWN (192.168.235.100)
2025/05/20 13:40:01 [46901] building file list
2025/05/20 13:40:01 [46901] sent 6293634 bytes received 156 bytes total size 6291456
2025/05/21 12:50:38 [61037] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:50:38 [61037] building file list
2025/05/21 12:50:38 [61037] sent 6293664 bytes received 190 bytes total size 6291456
2025/05/21 12:57:38 [61741] rsync on app/ from boss1@UNKNOWN (192.168.235.100)
2025/05/21 12:57:38 [61741] building file list
2025/05/21 12:57:38 [61741] sent 405 bytes received 35 bytes total size 6291456
'date+%F\ %T' fasheng/root/app/java/ CREATE 321.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 321.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 21.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 21.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 34.txt
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 34.txt
'date+%F\ %T' fasheng/root/app/java/ CREATE 322.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 322.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 333.java
'date+%F\ %T' fasheng/root/app/java/ MODIFY 333.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 66.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 66.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 67.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 68.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 68.java
'date+%F\ %T' fasheng/root/app/java/ CREATE 69.java
'date+%F\ %T' fasheng/root/app/java/ ATTRIB 69.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 21.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 321.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 322.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 333.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 34.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 35.txt
'date+%F\ %T' fasheng/root/app/java/ DELETE 66.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 67.java
'date+%F\ %T' fasheng/root/app/java/ CREATE aa4
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa4
'date+%F\ %T' fasheng/root/app/java/ CREATE aa5
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa5
'date+%F\ %T' fasheng/root/app/java/ DELETE 68.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 69.java
[root@code java]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 35 4月 19 17:20 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai
[root@code java]# /usr/local/bin/inotify.java
bash: /usr/local/bin/inotify.java: 沒有那個文件或目錄
[root@code java]# /usr/local/bin/inotify.sh
jobs
^C
[root@code java]# vim /usr/local/bin/inotify.sh
[root@code java]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date '+%F %T') fasheng$events" >> /var/log/rsync.log 2>&1
done [root@code java]# pkill -f inotify.sh
[root@code java]# /usr/local/bin/inotify/sh &
[1] 37918
[root@code java]# bash: /usr/local/bin/inotify/sh: 沒有那個文件或目錄
^C
[1]+ 退出 127 /usr/local/bin/inotify/sh
[root@code java]# /usr/local/inotify.sh &
[1] 37968
[root@code java]# bash: /usr/local/inotify.sh: 沒有那個文件或目錄
^C
[1]+ 退出 127 /usr/local/inotify.sh
[root@code java]# /usr/local/bin/inotify.sh &
[1] 37984
[root@code java]# chmod +x /usr/local/bin/inotify.sh &
[2] 38016
[root@code java]# jobs
[1]- 運行中 /usr/local/bin/inotify.sh &
[2]+ 完成 chmod +x /usr/local/bin/inotify.sh
[root@code java]# vim /usr/local/bin/inotify.sh
[root@code java]# cat /usr/local/bin/inotify.sh
#!/bin/bash
export TZ=Asia/Shanghai
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date '+%F %T') fasheng$events" >> /var/log/rsync.log 2>&1
done [root@code java]# touch /root/java/testfile
touch: 無法創建"/root/java/testfile": 沒有那個文件或目錄
[root@code java]# touch /root/app/java/testfile
[root@code java]# sending incremental file list
./
testfilesent 472 bytes received 48 bytes 346.67 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 426 bytes received 22 bytes 896.00 bytes/sec
total size is 0 speedup is 0.00
^C
[root@code java]# jobs
[1]+ 運行中 /usr/local/bin/inotify.sh &
[root@code java]# tail -n 5 /var/log/rsync.log
'date+%F\ %T' fasheng/root/app/java/ ATTRIB aa5
'date+%F\ %T' fasheng/root/app/java/ DELETE 68.java
'date+%F\ %T' fasheng/root/app/java/ DELETE 69.java
2025-05-24 19:42:29 fasheng/root/app/java/ CREATE testfile
2025-05-24 19:42:29 fasheng/root/app/java/ ATTRIB testfile
[root@code java]# touch /root/java/testfile2
touch: 無法創建"/root/java/testfile2": 沒有那個文件或目錄
[root@code java]# touch /root/app/java/testfile2
[root@code java]# sending incremental file list
./
testfile2sent 489 bytes received 48 bytes 1,074.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 443 bytes received 22 bytes 930.00 bytes/sec
total size is 0 speedup is 0.00
^C
[root@code java]# tail -5 /var/log/rsync.log
'date+%F\ %T' fasheng/root/app/java/ DELETE 69.java
2025-05-24 19:42:29 fasheng/root/app/java/ CREATE testfile
2025-05-24 19:42:29 fasheng/root/app/java/ ATTRIB testfile
2025-05-24 19:43:47 fasheng/root/app/java/ CREATE testfile2
2025-05-24 19:43:47 fasheng/root/app/java/ ATTRIB testfile2
[root@code java]# cat /usr/local/bin/inotify.sh
#!/bin/bash
export TZ=Asia/Shanghai
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date '+%F %T') fasheng$events" >> /var/log/rsync.log 2>&1
done [root@code java]# pkill -f inotify.sh
[1]+ 已終止 /usr/local/bin/inotify.sh
[root@code java]# nohup ./inotify.sh &
[1] 38600
[root@code java]# nohup: 忽略輸入并把輸出追加到"nohup.out"
nohup: 無法運行命令"./inotify.sh": 沒有那個文件或目錄
^C
[1]+ 退出 127 nohup ./inotify.sh
[root@code java]# cd /usr/local/bin
[root@code bin]# ls
inotify.sh inotifywait inotifywatch nohup.out
[root@code bin]# jobs
[root@code bin]# nohup ./inotify.sh &
[1] 39922
[root@code bin]# nohup: 忽略輸入并把輸出追加到"nohup.out"
jpnd
bash: jpnd: 未找到命令...
[root@code bin]# jobd
bash: jobd: 未找到命令...
[root@code bin]# jobs
[1]+ 運行中 nohup ./inotify.sh &
[root@code bin]# touch /root/app/java/testfile4.java
[root@code bin]# tail -5 /var/log/rsync.log
2025-05-24 19:42:29 fasheng/root/app/java/ ATTRIB testfile
2025-05-24 19:43:47 fasheng/root/app/java/ CREATE testfile2
2025-05-24 19:43:47 fasheng/root/app/java/ ATTRIB testfile2
2025-05-24 20:03:44 fasheng/root/app/java/ CREATE testfile4.java
2025-05-24 20:03:45 fasheng/root/app/java/ ATTRIB testfile4.java
[root@code bin]# vim /usr/local/bin/inotify.sh
[root@code bin]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date '+%F %T') fasheng$events" >> /var/log/rsync.log 2>&1
done [root@code bin]# pkill -f inotify.sh
[1]+ 已終止 nohup ./inotify.sh
[root@code bin]# nohup ./inotify.sh &
[1] 42179
[root@code bin]# nohup: 忽略輸入并把輸出追加到"nohup.out"
jobs
[1]+ 運行中 nohup ./inotify.sh &
[root@code bin]# touch /root/app/java/testfile8.java
[root@code bin]# tail -5 /var/log/rsync.log
2025-05-24 19:43:47 fasheng/root/app/java/ ATTRIB testfile2
2025-05-24 20:03:44 fasheng/root/app/java/ CREATE testfile4.java
2025-05-24 20:03:45 fasheng/root/app/java/ ATTRIB testfile4.java
2025-05-24 20:24:51 fasheng/root/app/java/ CREATE testfile8.java
2025-05-24 20:24:51 fasheng/root/app/java/ ATTRIB testfile8.java
[root@code bin]# rm -rf /root/app/java testfile2
[root@code bin]# tail -5 /var/log/rsync.log
2025-05-24 20:26:25 fasheng/root/app/java/ DELETE testfile2
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE nohup.out
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE testfile4.java
2025-05-24 20:26:27 fasheng/root/app/java/ DELETE testfile8.java
2025-05-24 20:26:27 fasheng/root/app/java/ IGNORED
[root@code bin]# ls /root/app/java
ls: 無法訪問/root/app/java: 沒有那個文件或目錄
[root@code bin]# cd /root/app/java
bash: cd: /root/app/java: 沒有那個文件或目錄
[root@code bin]# cd /root/app
[root@code app]# ;s
bash: 未預期的符號 `;' 附近有語法錯誤
[root@code app]# ls
[root@code app]# ls
[root@code app]# touch java
[root@code app]# ls
java
[root@code app]# cd java
bash: cd: java: 不是目錄
[root@code app]# mkdir /java
[root@code app]# ;s
bash: 未預期的符號 `;' 附近有語法錯誤
[root@code app]# ls
java
[root@code app]# cd java
bash: cd: java: 不是目錄
[root@code app]# mkdir /java
mkdir: 無法創建目錄"/java": 文件已存在
[root@code app]# ls
java
[root@code app]# cd java
bash: cd: java: 不是目錄
[root@code app]# rm rf java
rm: 無法刪除"rf": 沒有那個文件或目錄
rm:是否刪除普通空文件 "java"?y
[root@code app]# ls
[root@code app]# mkdir ./java
[root@code app]# ls
java
[root@code app]# touch ./java {1..4}.java
[root@code app]# cd java
[root@code java]# ls
[root@code java]# cd -
/root/app
[root@code app]# ls
1.java 2.java 3.java 4.java java
[root@code app]# touch -p ./java {1..4}.java
touch:無效選項 -- p
Try 'touch --help' for more information.
[root@code app]# cd ./java
[root@code java]# touch {1..4}.java
[root@code java]# ls
1.java 2.java 3.java 4.java
[root@code java]# tail -5 /var/log/rsync.log
2025-05-24 20:26:25 fasheng/root/app/java/ DELETE testfile2
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE nohup.out
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE testfile4.java
2025-05-24 20:26:27 fasheng/root/app/java/ DELETE testfile8.java
2025-05-24 20:26:27 fasheng/root/app/java/ IGNORED
[root@code java]# jobs
[1]+ 運行中 nohup ./inotify.sh &(工作目錄:/usr/local/bin)
[root@code java]# tail -10 /usr/local/bin/nohup.outsent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
[root@code java]# tail -20 /usr/local/bin/nohup.out
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
[root@code java]# kill -f inotify.sh
bash: kill: f: 無效的信號聲明
[root@code java]# pkill -f inotify.sh
[1]+ 已終止 nohup ./inotify.sh(工作目錄:/usr/local/bin)
(當前工作目錄:~/app/java)
[root@code java]# cd /usr/local/bin/
[root@code bin]# nohup ./inotify.sh &
[1] 44327
[root@code bin]# nohup: 忽略輸入并把輸出追加到"nohup.out"
jobs
[1]+ 運行中 nohup ./inotify.sh &
[root@code bin]# tail -6 /var/log/rsync.log
2025-05-24 20:26:25 fasheng/root/app/java/ DELETE testfile
2025-05-24 20:26:25 fasheng/root/app/java/ DELETE testfile2
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE nohup.out
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE testfile4.java
2025-05-24 20:26:27 fasheng/root/app/java/ DELETE testfile8.java
2025-05-24 20:26:27 fasheng/root/app/java/ IGNORED
[root@code bin]# cd /root/app/java
[root@code java]# ls
1.java 2.java 3.java 4.java
[root@code java]# cat /usr/local/bin/nohup.out
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
./inotify.sh:行4: 未預期的符號 `(' 附近有語法錯誤
./inotify.sh:行4: ` rsync -e(ssh -p 3712) -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup'
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
ssh: connect to host 192.168.235.100 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
sending incremental file list
deleting 66.java
deleting 35.txt
./sent 437 bytes received 50 bytes 324.67 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
deleting 67.java
./sent 418 bytes received 40 bytes 916.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
./
aa4
aa5sent 528 bytes received 67 bytes 396.67 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 443 bytes received 22 bytes 930.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 443 bytes received 22 bytes 930.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 443 bytes received 22 bytes 310.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
deleting 68.java
./sent 427 bytes received 36 bytes 926.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
deleting 69.java
./sent 410 bytes received 40 bytes 300.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
./
nohup.out
testfile4.javasent 588 bytes received 67 bytes 1,310.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 503 bytes received 22 bytes 350.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
./
testfile8.javasent 571 bytes received 48 bytes 1,238.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 525 bytes received 22 bytes 1,094.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 24.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
sending incremental file list
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
[root@code java]# tail -5 /usr/local/bin/nohup.out
rsync: change_dir "/root/app/java" failed: No such file or directory (2)sent 24 bytes received 12 bytes 72.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
[root@code java]# rsync -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup
sending incremental file list
deleting file7.java/
deleting file6.java/
deleting file5.java/
deleting file4.java/
deleting file3.java/
deleting file2.java/
deleting file1.java/
deleting aa3/
deleting aa2/
deleting aa1/
deleting testfile8.java
deleting testfile4.java
deleting testfile2
deleting testfile
deleting nohup.out
deleting file23.java
deleting file22.java
deleting file21.java
deleting file20.java
deleting file19.java
deleting aa5
deleting aa4
./
1.java
2.java
3.java
4.javasent 279 bytes received 387 bytes 1,332.00 bytes/sec
total size is 0 speedup is 0.00
[root@code java]# tail -5 /var/log/rsync.log
2025-05-24 20:26:25 fasheng/root/app/java/ DELETE testfile2
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE nohup.out
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE testfile4.java
2025-05-24 20:26:27 fasheng/root/app/java/ DELETE testfile8.java
2025-05-24 20:26:27 fasheng/root/app/java/ IGNORED
[root@code java]# ls
1.java 2.java 3.java 4.java
[root@code java]# touch 5.java
[root@code java]# tail -5 /var/log/rsync.log\
> ^C
[root@code java]#
[root@code java]# tail -5 /var/log/rsync.log
2025-05-24 20:26:26 fasheng/root/app/java/ DELETE testfile4.java
2025-05-24 20:26:27 fasheng/root/app/java/ DELETE testfile8.java
2025-05-24 20:26:27 fasheng/root/app/java/ IGNORED
2025-05-24 21:11:50 fasheng/root/app/java/ CREATE 5.java
2025-05-24 21:11:50 fasheng/root/app/java/ ATTRIB 5.java
[root@code java]# tail -5 /usr/local/bin/nohup.out
total size is 0 speedup is 0.00
sending incremental file listsent 141 bytes received 12 bytes 306.00 bytes/sec
total size is 0 speedup is 0.00
[root@code java]# tail -10 /usr/local/bin/nohup.out
sending incremental file list
./
5.javasent 187 bytes received 38 bytes 150.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file listsent 141 bytes received 12 bytes 306.00 bytes/sec
total size is 0 speedup is 0.00
[root@code java]# ssh -p 3333 code@192.168.235.100
Last login: Sat May 24 18:38:16 2025 from 192.168.235.20
[code@code ~]$ exit
登出
Connection to 192.168.235.100 closed.
[root@code java]# vim /usr/local/bin/inotify.sh
[root@code java]# cat /usr/local/bin/inotify.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /root/app/java |while read events
dorsync -av -e "ssh -p 3333" --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup/echo "$(date '+%F %T') fasheng$events" >> /var/log/rsync.log 2>&1
done [root@code java]# pkill -f inotify.sh
[1]+ 已終止 nohup ./inotify.sh(工作目錄:/usr/local/bin)
(當前工作目錄:~/app/java)
[root@code java]# nohup /usr/local/bin/inotify.sh &
[1] 48232
[root@code java]# nohup: 忽略輸入并把輸出追加到"nohup.out"
jobs
[1]+ 運行中 nohup /usr/local/bin/inotify.sh &
[root@code java]# ls
1.java 2.java 3.java 4.java 5.java nohup.out
[root@code java]# touch 7.java
[root@code java]# ls
1.java 2.java 3.java 4.java 5.java 7.java nohup.out
[root@code java]# tail -5 /var/log/rsync.log
2025-05-24 21:28:14 fasheng/root/app/java/ MODIFY nohup.out
2025-05-24 21:28:14 fasheng/root/app/java/ MODIFY nohup.out
2025-05-24 21:28:14 fasheng/root/app/java/ MODIFY nohup.out
2025-05-24 21:28:15 fasheng/root/app/java/ MODIFY nohup.out
2025-05-24 21:28:15 fasheng/root/app/java/ MODIFY nohup.out
[root@code java]# rsync -e "ssh -p 3333" -av --delete /root/app/java/ code@192.168.235.100:/home/code/backup/java_backup
sending incremental file list
nohup.outsent 1,200 bytes received 1,061 bytes 1,507.33 bytes/sec
total size is 119,281 speedup is 52.76
[root@code java]# cd /root/app/javqa
bash: cd: /root/app/javqa: 沒有那個文件或目錄
[root@code java]# cd /root/app/java
[root@code java]# ls
1.java 2.java 3.java 4.java 5.java 7.java nohup.out
[root@code java]# tail -10 nohup.out
sending incremental file list
nohup.outsent 1,594 bytes received 1,607 bytes 6,402.00 bytes/sec
total size is 183,011 speedup is 57.17
sending incremental file list
nohup.outsent 1,733 bytes received 1,607 bytes 2,226.67 bytes/sec
total size is 183,151 speedup is 54.84
[root@code java]# tail -20 nohup.out
sending incremental file list
nohup.outsent 1,941 bytes received 1,709 bytes 2,433.33 bytes/sec
total size is 195,191 speedup is 53.48
sending incremental file list
nohup.outsent 2,082 bytes received 1,709 bytes 7,582.00 bytes/sec
total size is 195,331 speedup is 51.52
sending incremental file list
nohup.outsent 1,499 bytes received 1,715 bytes 6,428.00 bytes/sec
total size is 195,471 speedup is 60.82
sending incremental file list
nohup.outsent 1,665 bytes received 1,715 bytes 2,253.33 bytes/sec
total size is 195,611 speedup is 57.87
[root@code java]# is 57. 1,715 bytes 2,253.33 bytes/sec
bash: is: 未找到命令...
[root@code java]# 1,715 bytes1,715 bytes list
bash: 1,715: 未找到命令...
[root@code java]# 2,433.33forever bytesforever
在這里插入代碼片
b:
[root@localhost java_backup]# date
2025年 05月 24日 星期六 08:10:28 CST
[root@localhost java_backup]# ls
35.txt aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java java
[root@localhost java_backup]# ll
總用量 6148
-rw-r--r--. 1 code code 6291456 5月 20 21:37 35.txt
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa1
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa2
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa3
-rw-r--r--. 1 code code 0 5月 20 21:38 file19.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file1.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file20.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file21.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file22.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file23.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file2.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file3.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file4.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file5.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file6.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file7.java
drwxr-xr-x. 12 code code 4096 5月 23 22:36 java
[root@localhost java_backup]# cd /home/code/backup/java_backup
[root@localhost java_backup]# ls
35.txt aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java java
[root@localhost java_backup]# cd java
[root@localhost java]# ls
21.java 321.java 322.java 333.java 34.txt 35.txt aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@localhost java]# ll
總用量 14336
-rw-r--r--. 1 code code 0 5月 23 22:18 21.java
-rw-r--r--. 1 code code 3145728 5月 23 22:07 321.java
-rw-r--r--. 1 code code 2097152 5月 23 22:26 322.java
-rw-r--r--. 1 code code 3145728 5月 23 22:36 333.java
-rw-r--r--. 1 code code 0 5月 23 22:22 34.txt
-rw-r--r--. 1 code code 6291456 5月 20 21:37 35.txt
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa1
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa2
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa3
-rw-r--r--. 1 code code 0 5月 20 21:38 file19.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file1.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file20.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file21.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file22.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file23.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file2.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file3.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file4.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file5.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file6.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file7.java
[root@localhost java]# cd -
/home/code/backup/java_backup
[root@localhost java_backup]# ls
21.java 321.java 322.java 333.java 34.txt 35.txt aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java java
[root@localhost java_backup]# ll
總用量 14340
-rw-r--r--. 1 code code 0 5月 23 22:18 21.java
-rw-r--r--. 1 code code 3145728 5月 23 22:07 321.java
-rw-r--r--. 1 code code 2097152 5月 23 22:26 322.java
-rw-r--r--. 1 code code 3145728 5月 23 22:36 333.java
-rw-r--r--. 1 code code 0 5月 23 22:22 34.txt
-rw-r--r--. 1 code code 6291456 5月 20 21:37 35.txt
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa1
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa2
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa3
-rw-r--r--. 1 code code 0 5月 20 21:38 file19.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file1.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file20.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file21.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file22.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file23.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file2.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file3.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file4.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file5.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file6.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file7.java
drwxr-xr-x. 12 code code 4096 5月 23 22:36 java
[root@localhost java_backup]# ll
總用量 14340
-rw-r--r--. 1 code code 0 5月 23 22:18 21.java
-rw-r--r--. 1 code code 3145728 5月 23 22:07 321.java
-rw-r--r--. 1 code code 2097152 5月 23 22:26 322.java
-rw-r--r--. 1 code code 3145728 5月 23 22:36 333.java
-rw-r--r--. 1 code code 0 5月 23 22:22 34.txt
-rw-r--r--. 1 code code 6291456 5月 20 21:37 35.txt
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa1
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa2
drwxr-xr-x. 2 code code 6 5月 19 22:32 aa3
-rw-r--r--. 1 code code 0 5月 20 21:38 file19.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file1.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file20.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file21.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file22.java
-rw-r--r--. 1 code code 0 5月 20 21:38 file23.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file2.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file3.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file4.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file5.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file6.java
drwxr-xr-x. 2 code code 6 5月 19 22:30 file7.java
drwxr-xr-x. 12 code code 4096 5月 23 22:36 java
[root@localhost java_backup]# dd if=/dev/zero of=12.java bs=12M count=1
記錄了1+0 的讀入
記錄了1+0 的寫出
12582912字節(13 MB)已復制,0.0460731 秒,273 MB/秒
[root@localhost java_backup]# ls
12.java 321.java 333.java 35.txt aa2 file19.java file20.java file22.java file2.java file4.java file6.java java
21.java 322.java 34.txt aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
[root@localhost java_backup]# ls
21.java 321.java 322.java 333.java 34.txt 35.txt aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@localhost java_backup]# ls
21.java 333.java aa1 file19.java file21.java file2.java file5.java
321.java 34.txt aa2 file1.java file22.java file3.java file6.java
322.java 35.txt aa3 file20.java file23.java file4.java file7.java
[root@localhost java_backup]# ls
21.java 333.java aa1 file19.java file21.java file2.java file5.java
321.java 34.txt aa2 file1.java file22.java file3.java file6.java
322.java 35.txt aa3 file20.java file23.java file4.java file7.java
[root@localhost java_backup]# ls
21.java 333.java aa1 file19.java file21.java file2.java file5.java
321.java 34.txt aa2 file1.java file22.java file3.java file6.java
322.java 35.txt aa3 file20.java file23.java file4.java file7.java
[root@localhost java_backup]# ls
21.java 333.java aa1 file19.java file21.java file2.java file5.java
321.java 34.txt aa2 file1.java file22.java file3.java file6.java
322.java 35.txt aa3 file20.java file23.java file4.java file7.java
[root@localhost java_backup]# ls
21.java 333.java 66.java 69.java aa3 file20.java file23.java file4.java file7.java
321.java 34.txt 67.java aa1 file19.java file21.java file2.java file5.java
322.java 35.txt 68.java aa2 file1.java file22.java file3.java file6.java
[root@localhost java_backup]# ls
21.java 321.java 322.java 333.java 34.txt 35.txt 66.java 67.java 68.java 69.java aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@localhost java_backup]# ls
21.java 321.java 322.java 333.java 34.txt 35.txt 66.java 67.java 68.java 69.java aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@localhost java_backup]# ls
322.java 333.java 34.txt 35.txt 66.java 67.java 68.java 69.java aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@localhost java_backup]# ls
34.txt 35.txt 66.java 67.java 68.java 69.java aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@localhost java_backup]# ls
34.txt 35.txt 66.java 67.java 68.java 69.java aa1 aa2 aa3 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@localhost java_backup]# ls
34.txt 66.java 68.java aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
35.txt 67.java 69.java aa2 file19.java file20.java file22.java file2.java file4.java file6.java
[root@localhost java_backup]# cat /etc/ssh/sshd_config
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.# This sshd was compiled with PATH=/usr/local/bin:/usr/bin# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 3712
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key# Ciphers and keying
#RekeyLimit default none# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO# Authentication:#LoginGraceTime 2m
PermitRootLogin No
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10#PubkeyAuthentication yes# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys#AuthorizedPrincipalsFile none#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none# no default banner path
#Banner none# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
[root@localhost java_backup]# netstat -tuln |grep 3712
tcp 0 0 0.0.0.0:3712 0.0.0.0:* LISTEN
tcp6 0 0 :::3712 :::* LISTEN
[root@localhost java_backup]# ls
35.txt 67.java 69.java aa2 file19.java file20.java file22.java file2.java file4.java file6.java
66.java 68.java aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
[root@localhost java_backup]# ls
35.txt 67.java 69.java aa2 file19.java file20.java file22.java file2.java file4.java file6.java
66.java 68.java aa1 aa3 file1.java file21.java file23.java file3.java file5.java file7.java
[root@localhost java_backup]# cat /etc/sshd/ssh_config
cat: /etc/sshd/ssh_config: 沒有那個文件或目錄
[root@localhost java_backup]# cd /etc/sshd
bash: cd: /etc/sshd: 沒有那個文件或目錄
[root@localhost java_backup]# cd /etc/ssh
[root@localhost ssh]# vim sshd_config
[root@localhost ssh]# cat sshd_config
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.# This sshd was compiled with PATH=/usr/local/bin:/usr/bin# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key# Ciphers and keying
#RekeyLimit default none# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO# Authentication:#LoginGraceTime 2m
PermitRootLogin No
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10#PubkeyAuthentication yes# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys#AuthorizedPrincipalsFile none#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none# no default banner path
#Banner none# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
[root@localhost ssh]# cd
[root@localhost ~]# cd /home/code
[root@localhost code]# cd backup
[root@localhost backup]# ls
java_backup
[root@localhost backup]# systemctl restart network
[root@localhost backup]# cd
[root@localhost ~]# cat /etc/ssh/sshd_config
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.# This sshd was compiled with PATH=/usr/local/bin:/usr/bin# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key# Ciphers and keying
#RekeyLimit default none# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO# Authentication:#LoginGraceTime 2m
PermitRootLogin No
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10#PubkeyAuthentication yes# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys#AuthorizedPrincipalsFile none#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none# no default banner path
#Banner none# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:e9:ad:9e brd ff:ff:ff:ff:ff:ffinet 192.168.235.100/24 brd 192.168.235.255 scope global noprefixroute ens33valid_lft forever preferred_lft forever
3: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000link/ether 52:54:00:f5:ea:28 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000link/ether 52:54:00:f5:ea:28 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]# tail -5 /etc/passwd
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
caozx26420:x:1000:1000:caozx26420:/home/caozx26420:/bin/bash
code:x:1001:1001::/home/code:/bin/bash
[root@localhost ~]# systemctl restart sshd
[root@localhost ~]# cd /home/code/backup/java_backup
[root@localhost java_backup]# ls
67.java aa1 file19.java file21.java file2.java file5.java
68.java aa2 file1.java file22.java file3.java file6.java
69.java aa3 file20.java file23.java file4.java file7.java
[root@localhost java_backup]# ls
68.java aa2 file1.java file22.java file3.java file6.java
69.java aa3 file20.java file23.java file4.java file7.java
aa1 file19.java file21.java file2.java file5.java
[root@localhost java_backup]# ls
68.java 69.java aa1 aa2 aa3 aa4 aa5 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java
[root@localhost java_backup]# ls
aa1 aa3 aa5 file1.java file21.java file23.java file3.java file5.java file7.java
aa2 aa4 file19.java file20.java file22.java file2.java file4.java file6.java
[root@localhost java_backup]# ls
aa1 aa4 file1.java file22.java file3.java file6.java testfile
aa2 aa5 file20.java file23.java file4.java file7.java testfile2
aa3 file19.java file21.java file2.java file5.java nohup.out testfile4.java
[root@localhost java_backup]# ls
aa1 aa2 aa3 aa4 aa5 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java nohup.out testfile testfile2 testfile4.java testfile8.java
[root@localhost java_backup]# ls
aa1 aa2 aa3 aa4 aa5 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java nohup.out testfile testfile2 testfile4.java testfile8.java
[root@localhost java_backup]# ls
aa1 aa2 aa3 aa4 aa5 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java nohup.out testfile testfile2 testfile4.java testfile8.java
[root@localhost java_backup]# ls
aa1 aa2 aa3 aa4 aa5 file19.java file1.java file20.java file21.java file22.java file23.java file2.java file3.java file4.java file5.java file6.java file7.java nohup.out testfile testfile2 testfile4.java testfile8.java
[root@localhost java_backup]# ls
1.java 2.java 3.java 4.java
[root@localhost java_backup]# ls
1.java 2.java 3.java 4.java 5.java
[root@localhost java_backup]# cat /etc/ssh/sshd_config
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.# This sshd was compiled with PATH=/usr/local/bin:/usr/bin# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key# Ciphers and keying
#RekeyLimit default none# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO# Authentication:#LoginGraceTime 2m
PermitRootLogin No
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10#PubkeyAuthentication yes# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys#AuthorizedPrincipalsFile none#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none# no default banner path
#Banner none# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
[root@localhost java_backup]# vim /etc/ssh/sshd_config
[root@localhost java_backup]# cat /etc/ssh/sshd_config
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.# This sshd was compiled with PATH=/usr/local/bin:/usr/bin# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 3333
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key# Ciphers and keying
#RekeyLimit default none# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO# Authentication:#LoginGraceTime 2m
PermitRootLogin No
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10#PubkeyAuthentication yes# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys#AuthorizedPrincipalsFile none#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none# no default banner path
#Banner none# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
[root@localhost java_backup]# [root@localhost java_backup]# ls
bash: [root@localhost: 未找到命令...
[root@localhost java_backup]# 1.java 2.java 3.java 4.java 5.java
bash: 1.java: 未找到命令...
[root@localhost java_backup]# .java .java 5.java
bash: .java: 未找到命令...
相似命令是: 'java'
[root@localhost java_backup]# systemctl restart sshd
[root@localhost java_backup]# ls
1.java 2.java 3.java 4.java 5.java 7.java nohup.out
[root@localhost java_backup]#
參考