Need to monitor a dir for files
Need to monitor a dir for files
if count > 0, sleep for 3min and check again for count and if count >0 then write to logfile. if count = 0 then write to logfile(no files available) |
Welcome to LQ
OK. Not sure what your question is... What have you tried? Please review the link in my signature, especially the link there about how to ask a question. |
Quote:
I tried the below #!/bin/bash dir="/tmp/test1/test" LOG_FILE="/tmp/test1/files_mon.log" >$LOG_FILE count=`find $dir -type f -ls | wc -l` if [ $count -ge 1 ]; then sleep 10s count=`find $dir -type f -ls | wc -l` if [ $count -ge 1 ]; then echo -e "Error : Files are not processed under dir $dir " >>$LOG_FILE else echo "INFO : All files are processed under dir $dir">>$LOG_FILE fi fi |
That script looks fine... except you don't deal with the == 0 case. What is the problem?
|
Quote:
Does that script not work? It looks like it should, except it doesn't match the specs in your OP. The sleep should be 180s or 3m (shorter for testing, perhaps?) What is supposed to be happening in the directory that would change the count? If that's not happening, you'll never get the else. There are but two tests in 10 secs, then the script is done. |
wouldn't it be better to use inotifywait/inotifywatch for this?
|
Quote:
|
All times are GMT -5. The time now is 11:05 AM. |