2
27
2013
1

Shell 总结(更新中)

弱智语言学的慢,零零碎碎就扔这里吧。。。

--more--

 

1. (2013-01-24)

今天把大段调度代码删了,变成一句话。。。白瞎了之前肉眼调试好几天。

 

本来有 /DIR/20130124(每天都有)/00(每个小时更新)/X.pack 好多pack,其中一些还可能在写,一个一个读很累。。还各种出错。。。

 

今天大删减,最后变成: 

all_files=$(find "/DIR/" -name "*.pack" -type f)

cat $all_files > all.pack

rm $all_files

 

由于cat也是磁盘速度,所以这段时间在写的文件肯定写完了,新生成的也不在我的all_file列表里,正常情况下绝不可能冲突!太nb了。

 

2. (2013-01-30)

 

上面那个代码弱爆了,谁写的,各种漏洞。看看修正版的吧:

 

all_files=$(find "$SYSDIR/recv_pool/" -type f -name "*.pack")

if [ ! "$all_files" = "" ]

then

    # Init all.pack

    if [ -e "${SYSDIR}/all.pack" ]

    then

        echo "@Warning: all.pack exist. backup OK."

        mv "${SYSDIR}/all.pack" "${SYSDIR}/all.pack.backup.${BTIME}"

    fi

    # Generate all.pack

    sleep 1

    echo $all_files | while read element

    do

        cat $element >> "$SYSDIR/all.pack"

        rm $element

    done 

fi

 

 

 

Category: 未分类 | Tags: linux | Read Count: 1337
Avatar_small
Emma 说:
2023年1月27日 03:55

Today, we have seen an example of how a large section of scheduling code can be reduced to one line of code, greatly improving efficiency. Before this change was made, manually debugging and reading through the packs was both real estate agent Spokane mentally and physically exhausting. This update is a great step forward, as it not only speeds up the process but also eliminates the potential for conflict due to newly generated files not being in the list. All in all, a very impressive update!


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com