Pause shell script till folder doesn't change size anymore


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pause shell script till folder doesn't change size anymore
# 8  
Old 07-05-2011
Yes, unless, for example, you're talking about /var/mobile in the system root, in which case you'll issue DIR='/var/mobile', as ~ denotes your Home directory
This User Gave Thanks to tukuyomi For This Post:
# 9  
Old 07-05-2011
I get line 5 error integer expression expected

I put the line with the dir like this:

DIR='/var/mobile/Media/"My Music"/'

Also, would it be possible to write the script without the "dostuff" and the "do other stuff ?

I only want this scriptpart to stop the script (withthat Loop you provided) Till the Folder Sizes remains the Same (e.g.doesn't change anymore).


EDIT:

Nevermind, if I use /var/mobile/Media/ as the Dir it works beutifully Smilie (seems that "My Music" makes problems...)

Thanks for this, its just what I needed Smilie

Last edited by pasc; 07-05-2011 at 01:50 PM..
# 10  
Old 07-05-2011
DIR='/var/mobile/Media/My Music/' will do.

You can write this script in a new script, of course:
(Call it for this example "pause.sh")
Code:
#!/bin/sh

get_size(){ du -s "$1" 2>/dev/null | awk '$0=$1';sleep 5;}

dir_size=$(get_size "$1")
while [ "$(get_size "$1")" -ne "$dir_size" ]; do
	echo 'Size has changed. Pausing 5 more seconds'
	dir_size=$(get_size "$1")
done

echo 'Size has not changed since the last 5 seconds.'

return 0

In your script, do the following:
Code:
#!/bin/sh

DIR=~/'unix.com'

echo "Do stuff"

./pause.sh "$DIR"

echo "Do other stuff"

exit 0

This User Gave Thanks to tukuyomi For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. UNIX for Dummies Questions & Answers

Shell Script for displaying the line till the target word

" Script for display sentences with special character" Hi, Could any one share a command how to display a line until my target word. For ex: My file has the content as: select * from db_wrk where col1 < col2 insert into table_name values('1','2','tst','wrk','dev','prod') My target... (10 Replies)
Discussion started by: Kalaiselvi66
10 Replies

3. Shell Programming and Scripting

UNIX script to get folder size

can any one help me with a unix command to find out the size of each directory for files placed between 2 dates i.e., date1 & date 2? (3 Replies)
Discussion started by: Codesearcher
3 Replies

4. Red Hat

Removing LVM Volume Group that doesn't exist anymore

Our SAN administrator decided to unpresent then destroy LUN's we were actively using as a volume group (all PV's in said volume group). Now every time I do a pvscan or whatever it complains about I/O errors trying to access those PV's. How do I get it to forget the VG existed completely? vgreduce... (7 Replies)
Discussion started by: thmnetwork
7 Replies

5. Shell Programming and Scripting

Log folder size monitoring script

Hi All, Can anyone refer to me a readymade script for the purpose of log folder size monitoring script. Example : I have a log folder of size 10 G, and as the logs keep accumulating the folder gets full and i have to manually zip/remove the files in order to keep the server running. Something... (1 Reply)
Discussion started by: findjai
1 Replies

6. Shell Programming and Scripting

How to introduce delay in Shell Script till a key stroke.

Hi All, How to introduce delay in the Bash/Shell Script till key stroke. Below is the requirement.. 1.Execute set of commands. 2.Display the message echo "press any key to continue" Introduce a delay till key stroke. 3.Execute next set of commands. Thanks in Advance Sunil.K (5 Replies)
Discussion started by: sunilrk07
5 Replies

7. Shell Programming and Scripting

How to pause a shell script

Hi, I've written a shell script to take photos with my camera. After every picture taken, the picture is transmitted to the computer via usb and then deleted on the camera. But sometimes there's an error and the picture is not deleted and so, after a certain time, the camera chip will be... (4 Replies)
Discussion started by: McLennon
4 Replies

8. UNIX for Dummies Questions & Answers

Sendmail not working anymore after resolv.conf change

Hi there, I am having a small issue with the mail function on our controllers. Recently we set up all the boxes as NFS slave servers and mail sending was not affected. We then had to change the servers addresses in resolv.conf and now email is being queued and not being sent. I have restarted... (3 Replies)
Discussion started by: lodey
3 Replies

9. UNIX for Dummies Questions & Answers

connection doesn't work anymore

Hello, first of all, I want to make myself clear about my language. I'm brazilian, so I ask you all to understand if i commit any mistake with the grammar. Here is the problem. Some days ago I needed to use a "sh" command in the Terminal (I use a Mac OSX 10.5.6) followed by a file... (0 Replies)
Discussion started by: anubisbr
0 Replies

10. AIX

how to change the font size of shell in $ prompt

Can any help me to change the default font type and its size.. To clear more about my question.. Once i login to my unix domain... the font it displaying is of small size... all my shell commands i am executing in $ prompt also carries the same style(ls, date and echo...) i searched whole... (2 Replies)
Discussion started by: tsjpraveen
2 Replies
Login or Register to Ask a Question