crontab 으로 vi 커맨드 실행시 딜레이 현상

lusilis의 이미지

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/&nbsp;//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 라는 파일로 만들고 싶을 때..

innu의 이미지

2초 딜레이가 뭘 의미하는지 모르겠네요.. :shock:

ps.

Quote:

$ cat test.txt | head -25 | tail -1 > tmp.txt

이러면 되지 않을까요?

Debian Spirit !!!

lusilis의 이미지

해당 줄이 작업을 마칠 때마다 현재 시간을 남기도록 했는데..

예를 들어 1번줄이 120110에 실행이 완료 됐다면..

2번줄에서 vi ~ 명령어가 실행 됐을 때 종료 시간이 120112가 된다는 뜻으로 적은겁니다.

위의 코드에 vi ~ 명령어가 3번 들어가니까 대략 6초 이상이 걸리는거죠. ㅠ_ㅠ)

sangwoo의 이미지

innu wrote:
2초 딜레이가 뭘 의미하는지 모르겠네요.. :shock:

ps.

Quote:

$ cat test.txt | head -25 | tail -1 > tmp.txt

이러면 되지 않을까요?

sed를 쓰시면 더 편할 듯 합니다.

$ sed -n '25p' test.txt >tmp.txt

----
Let's shut up and code.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.