Greetings,
I have searched through threads and online and cannot find anything that would help me in a specific way.
I am trying to check to see if 4 files listed in "files.txt" have tasks running on them.
Each file needs to be check for running tasks before moving on to the next file in the list.
example:
Code:
Checking file1
No change detected... checking file1
No change detected... checking file1
Tasks are running on file1
No change detected... checking file2
No change detected... checking file2
No change detected... checking file2
No change detected... checking file2
Tasks are running on file2
[...]
I have been trying to use md5sum to do the check --which does seem to work, except that my script is not checking to completion before moving on to the next file in the list.
Tasks have to be running before the script moves on.
The script I have works perfectly for a single file, but when I add a for loop, it fails to actually check...
Here is the script that works for a single file:
Code:
filename="/path/to/myfiles/file1"
lastfile=$(ls -l $filename)
while true
do
sleep 1
newfile=$(md5sum "$filename")
if [ "$newfile" != "$lastfile" ]
then
echo "Tasks are running on $filename"
lastfile="$newfile"
break
else
echo "Checking for running tasks on $filename"
fi
done
I need to be able to go through files listed in files.txt...
Which looks like this:
Code:
/path/to/myfiles/file1
/path/to/myfiles/file2
/path/to/myfiles/file3
/path/to/myfiles/file4
Here is the script for the loop:
Code:
for filename in $(cat files.txt); do
lastfile=`ls -l $filename`
while true
echo "Checking $filename"
do
sleep 1
newfile=`md5sum "$filename"`
if [ "$newfile" != "$lastfile" ]
then
echo "Tasks are running on $filename"
lastfile="$newfile"
break
else
echo "No change detected... $filename"
fi
done
done
The output I get is below:
Code:
-rw-rw-r-- 1 www www 1230 Oct 10 09:26 /path/to/myfiles/file1
1c05ebb1488d5dbfbcc0d34c2f7730d9 /path/to/myfiles/file1
Tasks Running /path/to/myfiles/file1
-rw-r--r-- 1 www www 1230 Oct 10 09:26 /path/to/myfiles/file2
c61d58de60268dc87194a3f76951b9cb /path/to/myfiles/file2
Tasks Running /path/to/myfiles/file2
-rw-r--r-- 1 www www 1229 Oct 10 09:26 /path/to/myfiles/file3
2204ee4bb052ccb13bb489a18a5962af /path/to/myfiles/file3
Tasks Running /path/to/myfiles/file3
-rw-r--r-- 1 www www 1229 Oct 10 09:26 /path/to/myfiles/file14
4f714eb328b7784b8485ce8a2538825b /path/to/myfiles/file4
Tasks Running /path/to/myfiles/file4
I have turned off updates to these files to see if the script is even working, and it is not...
I could really use some help with making this work, or... if someone knows a better way to do this -- Please let me know
Note -- I have no access to install software -- so I cannot add a 3rd party software to do this task... --I Wish--
Thanks in advance