really struggling with my last command in this script im trying to do
i want to capture the disk usage of the DIR in "to_be_archived" folder and a sleep command for 10 minutes and then run the disk usage command again to see if the two values change
if they have stop doing this DIR and do the next DIR in the "to_be_archived" folder
if the same values match, it can continue doing the tar/rsync/rm commands
im kind of thinking like this -
but i dont know how get it to do if the two values change exit, if they stay the same continue
the reason i have used the du --time command is it tells me the modification time and i would rather go by this than the folder size, if that makes sense
really struggling with my last command in this script im trying to do
i want to capture the disk usage of the DIR in "to_be_archived" folder and a sleep command for 10 minutes and then run the disk usage command again to see if the two values change
if they have stop doing this DIR and do the next DIR in the "to_be_archived" folder
if the same values match, it can continue doing the tar/rsync/rm commands
im kind of thinking like this -
but i dont know how get it to do if the two values change exit, if they stay the same continue
the reason i have used the du --time command is it tells me the modification time and i would rather go by this than the folder size, if that makes sense
thanks
Could you please explain why you have chosen to ignore my suggestion in post #40 in this thread to do what you are suggesting above?
What you are suggesting above is not only MUCH slower, but also error prone.
Why add 10 minutes of processing time to each directory you want to archive?
How do you know that a network delay or system scheduling won't stop whatever is copying files into a /to_be_archived/project directory for 10 minutes?
How will you know that something didn't accidentally kill the script copying files into a /to_be_archived/project directory before it completed successfully?
How will you know that the script copying files into a /to_be_archived/project directory didn't terminate because if was unable to copy a file (or perform some other action) before it completed?
How will you know that a bug in the script copying files into a /to_be_archived/project directory didn't cause the script to die before it completed its job?
All of these problems are avoided if you use the approach I suggested in post #40 in this thread. With the approach I suggested in post #40:
Scripts copying files into the /to_be_archived file hierarchy can operate independently from the script in this thread.
The script being discussed in this thread won't see a directory for a project to the archived until all files for that project have been successfully transferred into the corresponding /to_be_archived/project directory.
There is no need to slow down the script being discussed in this thread to try to determine if the directory for a project to be archived is ready to archive.
However, no matter what you do, you still need to verify that $DIR expands to an existing directory (as I mentioned in posts #16 and #24 in this thread).
And, I still question why you don't move the assignment command:
before your loop instead of resetting its value for each value of DIR you process.
so the operators, once they complete their projects, will move their project folders in the dir "to_be_archived" and once in there the script will take over/handle it and dump the output tar to dir "archived_projects"
lets say the operators have just started moving the project folder into the dir "to_be_archived" and my script is running and it intercepts the new project folder but the project folder is still growing in size, i dont want it to start of the process as they are still moving the project folder to the dir "to_be_archived"
thats why i want to put a wait command, to say if its stopped growing the project for 10 minutes it can start off the script but if its still growing, move on to the newxt project folder in the dir "to_be_archived"
---------- Post updated at 11:22 AM ---------- Previous update was at 07:05 AM ----------
so the operators, once they complete their projects, will move their project folders in the dir "to_be_archived" and once in there the script will take over/handle it and dump the output tar to dir "archived_projects"
lets say the operators have just started moving the project folder into the dir "to_be_archived" and my script is running and it intercepts the new project folder but the project folder is still growing in size, i dont want it to start of the process as they are still moving the project folder to the dir "to_be_archived"
... ... ...
Hi Robert,
You didn't pay close enough attention to what I suggested in post #40: I said it would be much better if you would create a hidden directory under /to_be_archived (such as /to_be_archived/.in_progress), have your operators move everything into a sub-directory under that directory (such as /to_be_archived/.in_progress/project), and then after that project directory contains everything your operators want to archive, have them issue the command:
Your existing script WILL NOT SEE /to_be_archived/.in_progress nor any directories under it. (That is why it is called a hidden directory.) After your operators have completed copying files into /to_be_archived/.in_progress/project, then, and only then, as the final step they issue the mv command that will make the completed project directory visible to your existing script.
If you don't believe that this works, run the following simple script to see that hidden directories will not be visible to your script:
which produces output similar to:
This User Gave Thanks to Don Cragun For This Post:
i see where your coming from Don and yes this would be easier but our operators, dont really know anything about command line terminology and there like old dogs (cant teach an old dog new tricks)
im doing this to make my life alot easier for myself ie so all they have to do is move thier project folders "to_be_archived" and once in there it will wait 10 minutes and if that project folder hasnt been modified in 10 minutes it will then tar/rsync and remove it
this is my final draft
thanks guys for all your help in this script, i really do mean it, i couldnt have done it without you guys
im still really rubbish at writting scripts btw
Last edited by robertkwild; 05-04-2016 at 08:39 AM..
HI Guys,
I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)
1. The problem statement, all variables and given/known data:
The task is to create a script that would reproduce the output of 'du' command, but in a different way: what 'du' does is:
<size> <folder name>and what is needed is
<folder name> <size>We need to show only 10 folders which are the... (3 Replies)
Good day, everyone!
I'm very new to bash scripting. Our teacher gave us a task to create a script that basically does the same job the 'du' command does, with the difference that 'du' command gives an output in the form of
<size> <folder name>and what we need is
<folder name> <size>As for... (1 Reply)
Hi All,
I have to requirement to write a shell script to move file from one folder (A) to another five folder (B,C,D,E,F) and destination folder should be blank. In not blank just skip.
This script will run as a scheduler every 2 minutes. It will check number of files in folder A and move 1 to... (9 Replies)
I would like to confirm my file.tar is been tar-ed correctly before I remove them. But I have very limited disc space to untar it.
Can I just do the listing instead of actual extract it? Can I say confirm folder integrity if the listing is sucessful without problem?
tar tvf file1.tar
... (1 Reply)
Hi all,
I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
I have 1000's of directories which is named as numbers. Each directory contains multiple files. Each of these directories have a file named "att". I need to rename all the att files by adding the directory name followed by "_" then att for each of the directories.
Directories
120
att... (2 Replies)
I have in directory /media/AUDIO/WAVE many .mp3 files with names like:
my filename_01of02.mp3
my filename_02of02.mp3
Your File_01of06.mp3
Your File_02of06.mp3
etc....
In the same directory, /media/AUDIO/WAVE, I have many folders with names like
9780743579490
9780743579491
etc..
Inside... (7 Replies)
I have written a shell script to perform backups using tar, rsync and optionally utilise lvm snapshots. The script is not finished but is in a working state and comments/descriptions are poor.
I would greatly appreciate any criticism and suggestions of the script to help improve my own learning... (0 Replies)
Hi.
I'm trying to copy multiple folders from the remote machine to the local machine. I wrote a batch file to run an ftp window.
The problem I am having is that the only command to copy files is mget *, and this copies only files, not folders.
For example, ftp ts555
cd ts555/test
' test... (5 Replies)