I'm trying to write a script which will do following :
- For any old log under trace directory, if found move it to Archive
- Check for a process “process-A” if it is running abort from the script
- Else start it up (start_process-A.sh this case)
- If it fails to start the process, exit with the appropriate exit code
- All of the above steps will be logged in the log file under trace
>>>> The above function moves all the files to the Archive directory as I used wildcard (*) but I want to keep the latest file (which will be generated upon completion of this script) in the trace directory and rest in the Archive directory. I have done lots of search in the google and just cannot find it. Any help will be appreciated.
>> Is there a was to check the start_process-A.sh script is failed or hung? if so how do I redirect it to the log file?
Last edited by Franklin52; 09-16-2010 at 02:57 AM..
Reason: Please use code tags, thank you!
For the future please use [CODE] tags around the logic. Please review the forum rules.
Let's assume(might not a good assumption) that start_process-A.sh will return a non-zero return code on error. You can check the return code just like you did with the grep. This gets more complicated when trying to check the return code from a program in the pipeline. Do you really need use tee? Can you just append(>>) to ${LOGFILE}? If you really need the output in the current script and the log file then you have to be more creative. I will wait for you response before going down that route. Do you know if the shell is ksh93?
Hi,
Could you please assist how to move the gz files which are older than the 90 days from one folder to another folder ,before that it need to check the file system named "nfs" if size is less than 90 or not. If size is above 90 then it shouldn't perform file move and exit the script throwing... (4 Replies)
Hi Unix Experts,
I am new in this filed.
I have assignment to Archive and purge the log file using shell scripts I tried I could not get the result please help me this.
Ex: test.log
requirement : using shell script I need to archive the log file and nil and the content of (test.log)... (1 Reply)
Hi All,
I am coding for a requirement where I need to read a file & get the values of SUB_DATE. Once the dates are found, i need to move the files based on these dates from one directory to another.
ie, this is how it will be in the file,
SUB_DATE = 20120608,20120607,20120606,20120606... (5 Replies)
Hi Experts,
I have a "Source" folder which may contain some files. I need a shell script which should move all files which are older than 3 days to "Archive" folder.
Thanks in Advance... (4 Replies)
Hi,
I have a data file that lists a number of files. I want to move the files named in that one to another directory. Here's what I have:
#!/usr/bin/perl -w
open(FILE, "<collision.txt");
my @lines=<FILE>;
foreach my $lines (@lines) {
system("mv $lines collisions/.");
}
close(FILE);
... (2 Replies)
Hi ,
I want to write a FTP Script which checks the No of Vesions of the files in Archive Dir and if count >= 8 Delete the oldest file from the Archive Dir and if the count is <= 8 Move the file to the Archive Dir with a CurrentDate concatenation and FTP the file to the FTP directory and send... (1 Reply)
hi
i am reading files from directory,if the files matches certain condition i need to move that file to another directory
i am using
if
then
mv $file1 > $UNIQDIR
fi
but i am gettin error , please help
thanks
Satya (4 Replies)
Can any one help me to correct following script.
I have 2 directories DropZone and ProcessZone. File pattern is *VEHDESCSUM*.
Finding the 'no of files' in DropZone directory using ls *VEHDESCSUM* |wc -l
If DropZone has more than one file or 0 files then exit 1
If DropZone has one file then... (2 Replies)
Hi,
After checking all the UNIX threads, I am able to come up with a solution so far. I am working on a shell script where it moves the files to a certain directory. The conditions to check are
1) Check if the file exists in the current directory.
2) Check if the destination directory... (2 Replies)