Register
It is currently Wed Dec 13, 2017 10:25 pm

Wait and continue if directory stays same size


All times are UTC - 6 hours


Post new topic Reply to topic  [ 7 posts ] 
Author Message
 PostPosted: Mon Apr 25, 2016 2:43 pm   

Joined: Tue Apr 12, 2016 4:11 am
Posts: 51
hi all,

i want to make a bash script so it can monitor directory sizes ie if it stays the same size (for a certain time) i want it to run the script but if there still copying and the directory increases in size do not run the script

i have heard "inotifywait" can do this, but theres others aswell

watch
inotifywatch

cheers,

rob
Edit/Delete Unix or Linux Message


Top
 Profile  
 PostPosted: Mon Apr 25, 2016 3:33 pm   

Joined: Tue Apr 12, 2016 4:11 am
Posts: 51
will this work, if i put it in an if statement -

inotifywait -mrq -e access,modify,close,open,create,delete -t 180 /to_be_archived/"$DIR"


Top
 Profile  
 PostPosted: Mon Apr 25, 2016 3:44 pm   

Joined: Mon Oct 20, 2014 9:53 am
Posts: 560
You need a loop too as inotifywait will exit when timeout occurs OR an event it listens to occured.
Hence call in the loop inotifywait and check return code.

See man inotifywait


Top
 Profile  
 PostPosted: Wed Apr 27, 2016 3:40 am   

Joined: Tue Apr 12, 2016 4:11 am
Posts: 51
i did this but it doesnt work over NFS, i will have to use the du command with some variables in it

inotifywait -rq -e modify,create,delete -t 60 /vol/cha-work/to_be_archived/audio/auto_archive/


Top
 Profile  
 PostPosted: Wed Apr 27, 2016 7:03 am   

Joined: Mon Oct 20, 2014 9:53 am
Posts: 560
innotifywait uses the kernel input/output subsystem for block devices.
Hence it works on local block devices only.
It just can't get it hands on remote filesystems.
Be it NFS or anything else.


Top
 Profile  
 PostPosted: Wed Apr 27, 2016 3:49 pm   

Joined: Tue Apr 12, 2016 4:11 am
Posts: 51
just thinking, would find command do this?


Top
 Profile  
 PostPosted: Wed Apr 27, 2016 5:06 pm   

Joined: Mon Oct 20, 2014 9:53 am
Posts: 560
There are some commands being able to output size of files.

No matter which you use you have to do some math on your own and calcuelate sizes. sum em up and then decide what to do when.

Of course you can use find to output the size.
See man find. Something like find . -printf "%s\n"


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP