Filewatcher


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filewatcher
# 1  
Old 10-21-2014
Filewatcher

hi All,

I ned to write a filewatcher script, with following requirements.

1. The script should look for the file in every 5 min.
2. If the file is found, it should check in every 3 min the size of file.
3. if the file size has not changed in last 4 iterations (i.e. in last 12 min), the script should exit.
4. if the file size changes, the script should check in every 3 min untill for last 4 iterations the files size does not change.


I am successfully able to write script which satisfy 1st condition but satisfying 2,3& 4 condition is tricky for me.

All the iteration (i.e. for file check & file size checks)
should be configurable i.e passed as arguments to script.


Appreciate your help!!
# 2  
Old 10-21-2014
Post the script so far.
# 3  
Old 10-21-2014
Here are a couple of clues:

Depending on your OS, you may be able to use the stat command to fetch a file size:

Code:
size=$(stat -c %s $filename)

If you don't have stat available you are probably going to have to use cut or awk to strip the size from ls -l $filename output.

You can test the size of integers with -lt like this:

Code:
if [ $size -gt $prev_size ] 
then
     echo "File is still growing"
else
     ((same++))
fi
prev_size=$size

Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generic Filewatcher

Hi, I have a requirement wherein i need to have a generic file watcher in place. On presence of a file in a particular directory,the file watcher should identify the related config file and execute the series of the shell scripts mentioned in the config file. eg.Config file a.sh b.sh... (7 Replies)
Discussion started by: dikesm
7 Replies

2. UNIX for Dummies Questions & Answers

Filewatcher job

Hi Friends iam using a filewatcher job which checks the path in intervals below is the script #!/bin/ksh fileflag=0 timer1=0 check_interval=120 # check every 2 minutes (( check_interval_minutes=${check_interval}/60 )) while do if then echo "My file exists now..." | mailx -s... (7 Replies)
Discussion started by: robertbrown624
7 Replies

3. Shell Programming and Scripting

Autosys filewatcher + ksh script

Hi, A ------> B ------> C I have a scenario where each day, my server B would ftp to server A and pull (A,B,C,D,E) from a specific directory. Server C would need files (B,D) only when server B finished receiving from server A. These files change everyday, so sometimes it takes longer... (3 Replies)
Discussion started by: arex876
3 Replies

4. Shell Programming and Scripting

FileWatcher Script

Hi All, Sorry to post these many questions on UNIX. i am new to unix & got only UNIX work in my organization. I need to make a script for File Arrival Check. 1. The script should wait for indicator file for configured amount of time. 2. If the file is not received after the configured... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies

5. Shell Programming and Scripting

Problem with filewatcher...

Hi everyone, Please find the script for Filewatcher rule file,which does the simple job of moving the files whenever it dectects to another directory.And whenever it detects the cmd_mm.stop file,it should terminate the job. INTERVAL 60 ON_FILEWATCH ${HLD}/CMD/* CREATE 0 1 2 0400 5 THEN... (2 Replies)
Discussion started by: bhagat.singh-j
2 Replies
Login or Register to Ask a Question