捕获“ rm:fts_read:没有此类文件或目录”错误并继续

时间:2018-08-19 21:27:31

标签: bash macos unix rm

我真讨厌Macbook。我将一些Time Machine备份从外部驱动器移到$(document).ready(function () { function countdown() { var bt = "23:00", // 11:00 PM wt = "08:00"; // 08:00 AM var today = new Date(), dd = today.getDate(), mm = today.getMonth()+1, yyyy = today.getFullYear(); var startTime = new Date(mm + '/' + dd + '/' + yyyy + ' ' + wt), endTime = new Date(mm + '/' + dd + '/' + yyyy + ' ' + bt); setInterval(function() { var now = new Date(); var nowdd = today.getDate(); var nowTime = now.getTime(); if(dd !== nowdd) { dd = nowdd; startTime = new Date(dd + '/' + mm + '/' + yyyy + ' wt'); endTime = new Date(dd + '/' + mm + '/' + yyyy + ' bt'); } if(nowTime > startTime && nowTime < endTime) { // Find the distance between now and the count down date var distance = endTime - nowTime; // Time calculations for days, hours, minutes and seconds var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)), minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)), seconds = Math.floor((distance % (1000 * 60)) / 1000); $("#countDown").val(hours + ":" + minutes + ":" + seconds); } else { $("#countDown").val("00:00:00"); } }, 1000); } countdown(); }); 中,并很快意识到这是一个可怕的错误。我不能放回去,也不能删除它们。到目前为止,我一直在使用名为$dt = date('Y-m-d', strtotime('1995-02-27')); // maybe filled dynamically $sql = "SELECT event FROM LifeEvents WHERE event_date > '$dt'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo $row["event"] . "<br>"; } } else { echo "0 results"; } $conn->close(); 的辅助功能运行Trash,这使我可以绕过Apple对删除备份的保护。

反正我有一个命令

rm

为简洁起见,可以简称为

bypass

会不断被sudo /System/Library/Extensions/TMSafetyNet.kext/Contents/Helpers/bypass rm -rfv /Volumes/*/.Trashes 打断。我认为fts_read本质上是一个UNIX内核函数,它进入文件空间并在非常冗长的递归sudo bypass rm -rfv /Volumes/*/.Trashes 调用期间作为文件读取。因此,我想捕获rm: fts_read: No such file or directory并重新启动rm。我不太了解bash,但这是我的一些伪代码:

fts_read

基本上现在,我每次收到错误时都会手动重新启动命令,但是此过程要花费数十个小时,因此可以自行重新启动会很好。

1 个答案:

答案 0 :(得分:1)

一个可能的选项可能是需要上一条命令失败的while循环?例如:

counter=0
cd "not a real place" #get the initial error code
while [[ $? -ne 0 ]]; do
    echo 'words'
    (( counter++ ))
    (( counter > 10 ))
done

这将一直持续到(( counter > 10 ))返回0,即计算结果为true为止。您应该能够使用命令执行类似的操作:

sudo bypass rm -rfv /Volumes/*/.Trashes
while [[ $? -ne 0 ]]; do
    sudo bypass rm -rfv /Volumes/*/.Trashes
done

我怀疑这是一个好的解决方案,但这是 a 解决方案。