开发者

Suggesion on using java or shell script

开发者 https://www.devze.com 2022-12-19 20:40 出处:网络
One third party application writes data to log file. Data format is text. Log file (say orig.log) is created daily. Maximum size of log file is set to 1 GB. Requirement is to to write a program

One third party application writes data to log file. Data format is text. Log file (say orig.log) is created daily. Maximum size of log file is set to 1 GB. Requirement is to to write a program

开发者_开发百科
  1. Which will rename this log file(to say temp.log) and change some records as per requirement.

  2. Program will append the entire contents of this log file to some other file(say-Processed.log).

  3. Program will delete temp.log.

  4. Program will be like scheduler-should be able to perform 1,2,3 at specific time interval like 15 minutes/1 Hr etc

Is java suitable for this? or Shell Script? any other option? (all files, third party application and this program will be on same machine).


Personally, if it's log file manipulation, I'd use perl or python. (As for scheduling every 15 minutes, that's what cron is for.)

If the "change some records" is simple enough, you can probably combine the first two steps into a perl, python, awk or even sed pipe.

perl foo.pl < orig.log >> Processed.log


Shell script is really well suited for this use.

step one is only mv orig.log temp.log you could use awk or sed for step 2 and so on

for the scheduling part cron might do the job (^^)

Finally you may take into account which one you know best.


Is java suitable for this?

Yes, and it will be pretty straight forward if you command it.

or Shell Script?

Yes, it depends on what are you more familiar with.

any other option?

I would use a different programming language, since Python has already been mentioned, I would add Ruby, it is great at this kind of jobs also.

0

精彩评论

暂无评论...
验证码 换一张
取 消