crontab 으로 vi 커맨드 실행시 딜레이 현상
글쓴이: lusilis / 작성시간: 수, 2005/10/12 - 6:11오후
Redhat 9 (2.6.6) / Apache 서버를 사용하고 있습니다.
wget 으로 특정 웹페이지를 읽어와 그중에서 필요한 부분만 검색후 파일로 저장 하는 쉘을 하나 실행하는데..
터미널 상에서 직접 실행시에는 아무런 딜레이 없이 실행이 완료 되지만 해당 쉘을 cron 에서 실행하면 특정 커맨드에서 딜레이 현상이 생깁니다.
servers=(www1 www2 www3) server_no=${#servers[@]} server_index=0 while [ "$server_index" -lt "$server_no" ] do server=${servers[$server_index]} wget http://${server}.abc.com/admin.html -O ${server} vi -c "29,30 co $" -c "35,36 co $" -c "44 co $" -c "wq" ${server} cat server/${server} >> ${server}-1 tail -n 5 ${server} >> ${server}-1 vi -c "%s/ <td>//g" -c "%s/<td>//g" -c "%s/<tr>//g" -c "%s/<th>//g" -c "%s/<th colspan='3'>//g" -c "%s/jdbc\///g" -c "%s/ //g" -c "wq" ${server}-1 find ${server} -exec egrep -i "<td>-1" {} \; >> ${server}-2 vi -c "%s/ <td>//g" -c "%s/<td>/:/g" -c "wq" ${server}-2 cat ${server}-2 | awk -F: '{print $1}' >> ${server}-3 cat ${server}-3 >> ${server}-1 mv ${server}-1 tmp/${server}_end rm -f ${server} ${server}-* let "server_index = $server_index +1" done
조잡하기 그지 없는 소스죠.. ;;
문제는 실행중 로그를 찍어보니 vi ~ 명령이 실행 될 때마다 2초라는 딜레이가 발생하는데..
명령어 종료 시점을 정의하는 뭔가가 있는것인지 아니면 원래 그렇게 발생하는 문제인지 알수가 없어 이렇게 글을 올립니다.
관련 지식이 있으신분은 도움 부탁드립니다.
PS - 추가로 소스에서 특정 열만 뽑아낼 수 있는 방법이 있다면 부탁드립니다.
ex) 총 100줄인 소스에서 25번째 줄을 뽑아 tmp.txt 라는 파일로 만들고 싶을 때..
Forums:
2초 딜레이가 뭘 의미하는지 모르겠네요.. :shock: ps.
2초 딜레이가 뭘 의미하는지 모르겠네요.. :shock:
ps.
이러면 되지 않을까요?
Debian Spirit !!!
위에서 딜레이 현상이란..
해당 줄이 작업을 마칠 때마다 현재 시간을 남기도록 했는데..
예를 들어 1번줄이 120110에 실행이 완료 됐다면..
2번줄에서 vi ~ 명령어가 실행 됐을 때 종료 시간이 120112가 된다는 뜻으로 적은겁니다.
위의 코드에 vi ~ 명령어가 3번 들어가니까 대략 6초 이상이 걸리는거죠. ㅠ_ㅠ)
[quote="innu"]2초 딜레이가 뭘 의미하는지 모르겠네요.. :s
sed를 쓰시면 더 편할 듯 합니다.
----
Let's shut up and code.
댓글 달기