최근에는 백그라운드에서 스크립트를 실행하고 다른 컴퓨터의 출력을 모니터링할 수 있어야 했습니다. 이러한 이유로 다음 명령을 사용할 수 있었습니다.
$ nohup ./rsync.sh > ./output.txt
rsync.sh
스크립트에 포함된 내용은 다음과 같습니다 .
#!/bin/bash
set -ex
rsync -av --progress /home/martins/Documents/Copy/CopyFrom/ /home/martins/Documents/Copy/CopyTo/
echo "Done syncing!"
유일한 문제는 output.txt
파일을 업데이트할 때마다 파일이 계속 커지는 것 입니다.추가의파일로 출력합니다.
output.txt
덮어쓰고 싶어요현재 최신내 스크립트의 출력입니다.
그렇지 않으면 다음과 같은 출력 파일이 생성됩니다.
32,768 0% 47.98kB/s 23:34:33
9,994,240 0% 9.49MB/s 0:06:57
34,897,920 0% 16.60MB/s 0:03:57
56,131,584 1% 17.80MB/s 0:03:40
75,792,384 1% 18.01MB/s 0:03:36
103,579,648 2% 22.25MB/s 0:02:54
125,337,600 3% 21.48MB/s 0:02:59
148,406,272 3% 21.91MB/s 0:02:54
170,164,224 4% 22.43MB/s 0:02:49
192,446,464 4% 21.10MB/s 0:02:59
213,090,304 5% 20.86MB/s 0:03:00
238,845,952 5% 21.51MB/s 0:02:53
264,273,920 6% 22.37MB/s 0:02:46
288,391,168 7% 22.78MB/s 0:02:42
311,721,984 7% 23.35MB/s 0:02:37
335,577,088 8% 22.89MB/s 0:02:39
360,480,768 8% 22.69MB/s 0:02:39
384,860,160 9% 22.79MB/s 0:02:37
412,745,728 10% 23.94MB/s 0:02:29
437,551,104 10% 24.17MB/s 0:02:26
466,386,944 11% 25.19MB/s 0:02:19
492,077,056 12% 25.47MB/s 0:02:17
514,883,584 12% 24.26MB/s 0:02:23
540,573,696 13% 24.43MB/s 0:02:21
566,263,808 13% 23.69MB/s 0:02:24
590,872,576 14% 23.48MB/s 0:02:24
616,595,456 15% 24.17MB/s 0:02:19
642,809,856 15% 24.27MB/s 0:02:17
668,762,112 16% 24.36MB/s 0:02:16
693,927,936 17% 24.42MB/s 0:02:15
719,355,904 17% 24.34MB/s 0:02:14
746,356,736 18% 24.59MB/s 0:02:12
776,044,544 19% 25.50MB/s 0:02:06
802,717,696 19% 25.91MB/s 0:02:03
825,524,224 20% 25.31MB/s 0:02:05
849,379,328 20% 24.48MB/s 0:02:08
875,855,872 21% 23.70MB/s 0:02:11
904,691,712 22% 24.21MB/s 0:02:07
931,954,688 22% 25.21MB/s 0:02:01
957,120,512 23% 25.56MB/s 0:01:59
984,973,312 24% 25.91MB/s 0:01:56
1,013,219,328 24% 25.63MB/s 0:01:56
1,044,676,608 25% 26.60MB/s 0:01:51
1,077,182,464 26% 28.34MB/s 0:01:43
1,104,969,728 27% 28.24MB/s 0:01:42
1,138,262,016 27% 29.54MB/s 0:01:36
1,163,067,392 28% 28.05MB/s 0:01:41
1,189,380,096 29% 26.64MB/s 0:01:45
1,211,924,480 29% 25.46MB/s 0:01:49
1,234,665,472 30% 23.00MB/s 0:02:00
1,260,683,264 30% 23.27MB/s 0:01:57
1,284,014,080 31% 22.47MB/s 0:02:01
1,312,325,632 32% 23.81MB/s 0:01:53
1,341,947,904 32% 25.39MB/s 0:01:44
1,368,948,736 33% 25.64MB/s 0:01:42
1,393,917,952 34% 26.12MB/s 0:01:40
1,418,756,096 34% 25.27MB/s 0:01:42
1,442,349,056 35% 23.87MB/s 0:01:47
1,468,563,456 36% 23.69MB/s 0:01:47
1,498,710,016 36% 24.93MB/s 0:01:40
1,530,429,440 37% 26.62MB/s 0:01:33
1,556,905,984 38% 27.30MB/s 0:01:29
1,587,314,688 38% 28.28MB/s 0:01:25
1,616,936,960 39% 28.09MB/s 0:01:25
1,643,413,504 40% 26.85MB/s 0:01:28
1,674,608,640 41% 27.96MB/s 0:01:23
1,707,343,872 41% 28.53MB/s 0:01:20
1,732,280,320 42% 27.47MB/s 0:01:23
1,758,756,864 43% 27.46MB/s 0:01:22
1,790,214,144 43% 27.47MB/s 0:01:21
1,811,709,952 44% 24.70MB/s 0:01:29
1,837,268,992 45% 24.86MB/s 0:01:27
1,863,090,176 45% 24.67MB/s 0:01:27
1,894,023,168 46% 24.59MB/s 0:01:26
1,922,072,576 47% 26.24MB/s 0:01:20
1,952,219,136 47% 27.28MB/s 0:01:15
1,979,023,360 48% 27.56MB/s 0:01:14
2,008,121,344 49% 27.18MB/s 0:01:14
2,037,678,080 50% 27.51MB/s 0:01:12
2,068,086,784 50% 27.62MB/s 0:01:10
2,096,136,192 51% 27.87MB/s 0:01:09
2,120,515,584 52% 26.66MB/s 0:01:11
2,147,811,328 52% 26.15MB/s 0:01:11
2,172,682,240 53% 24.80MB/s 0:01:14
2,200,403,968 54% 24.77MB/s 0:01:13
2,228,518,912 54% 25.72MB/s 0:01:09
2,257,616,896 55% 26.13MB/s 0:01:07
2,288,025,600 56% 27.47MB/s 0:01:03
2,316,599,296 56% 27.58MB/s 0:01:02
2,347,008,000 57% 28.10MB/s 0:00:59
2,375,843,840 58% 28.02MB/s 0:00:59
2,407,301,120 59% 28.28MB/s 0:00:57
2,436,136,960 59% 28.43MB/s 0:00:56
2,465,693,696 60% 28.28MB/s 0:00:55
2,492,235,776 61% 27.73MB/s 0:00:55
2,520,547,328 61% 26.99MB/s 0:00:56
2,547,286,016 62% 26.46MB/s 0:00:56
2,575,335,424 63% 26.09MB/s 0:00:56
2,603,909,120 63% 26.59MB/s 0:00:53
2,702,147,584 66% 43.25MB/s 0:00:30
3,271,327,744 80% 172.58MB/s 0:00:04
3,817,537,536 93% 296.24MB/s 0:00:00
4,071,903,232 100% 38.11MB/s 0:01:41
sent 4,492,670,113 bytes received 209 bytes 39,237,295.39 bytes/sec
total size is 4,491,572,666 speedup is 1.00
+ echo 'Done syncing!'
Done syncing!
답변1
의견에 명시된 대로 문제는 nohup
제공하는 옵션이 아닙니다 rsync
. 스크립트의 명령을 다음으로 변경하십시오.
rsync -aq /home/martins/Documents/Copy/CopyFrom/ /home/martins/Documents/Copy/CopyTo/
그리고 더 읽기 쉬운 로그 파일이 있어야 합니다.