-1

A feature will be launched which will create logs as the run proceeds. So, I have to write a script which will keep on checking a directory during runtime of the about feature if there are any log files created or no and incase if I see the logs being created, I will do further actions. The tricky part here is I do not have access to watch, cron jobs or anything like that at customer site so any other suggestion would be appreciated. Also, I cannot install any python libraries, so I need something very basic.

I haven't yet tried but looking to see if any function exists, I am planning to use while loop to keep monitoring the directory.

4
  • Don't reinvent the wheel (unless your boss is making you <-;!) . stackoverflow.com/a/19733629/620097 can help. Good luck. Commented Jan 27, 2023 at 23:32
  • Hey I saw the command inotifywait but it says "command not found". I gues this doesnt work in our environment too. Commented Jan 28, 2023 at 0:03
  • what do you get with uname -srv ? Also, it may be in a "special" directory not on your normal path.. It may also just be named as inotiify AND there are other similar feature packages. See you can get it installed, better use of your time. Ask around at your work site. AND there is almost certainly code someplace here on S.O. that will do this, so sharpen up your searching skills (-;! Good luck. Commented Jan 28, 2023 at 0:11
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Jan 28, 2023 at 9:38

1 Answer 1

1

If you cannot convince the client to install inotify-tools in order to have access to inotifywait, then you need to keep track of not only the existence of an output file, but, more important, is the output file closed (is the process finished with that file).

In other words the process creating the file would have a second "flag file" (call it ${process_name}.writing) which would be created before output and removed when output completed.

As for conditional logic, if output.txt exists and ${process_name}.writing does not, then the output.txt is complete and usable.

You can always consider use of the flock utility to test/assign reserved use of file in order to ensure no conflicts in acquisition of "closed" files.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.