Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Moving file using shell script fails occasionally Post 303046007 by Sac on Tuesday 21st of April 2020 01:43:06 PM
Old 04-21-2020
Moving file using shell script fails occasionally

Hi,
I am trying to copy a file to "B" directory also once it is done, i am trying to move the files to "C" directory.
And have written the below code to do so.

Code:
cd / 

rm script116.source116.file

SOURCEONEACTUAL="a"
SOURCEONENEW="b"

ls -lrth $SOURCEONEACTUAL116 | awk '{print $9}' |grep -v temp > script.source.file

while read line
do
cd  $SOURCEONEACTUAL
cp $line $SOURCEONEACTUAL/temp/
mv $line $SOURCEONENEW

done < script.source.file

date

The code works fine, but sometimes i am seeing the file count mismatch from b directory to c directory.
I have enabled the code in cronjob to carry out the process once in every hour as file count will be huge.

Need suggestion on below points
1. How can i add the logs to identify the problem.
2. And what might be the problem where it is not able to move all the files to new directory after the copy.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need shell script for moving file one by one

#SD=source dir TD= target dir SD="$/amddev/app01/manoj/new/scripts/old" TD="$/amddev/app01/manoj/new/scripts/new" EXT="$*.txt" for i in `ls -F "$SD"/*"$EXT"|grep -v /$` do mv "$SD" "$TD" if then echo "$i" successfully moved echo Manoj successfully..1 ( here i... (8 Replies)
Discussion started by: manojkarthi
8 Replies

2. Shell Programming and Scripting

why shell script fails

hi .. I have automate some process on unix through sehll script . but i don't know there is some problem in scripts, some time shell script works and some time it fails. so my query is that "Why shell script fails some times?" thanks (4 Replies)
Discussion started by: tahir23
4 Replies

3. Shell Programming and Scripting

why shell script fails?

hi , i m trying to run a shell script automatically , some time it works fine but some time it fails , what could be the problem . If anybody have an idea about this problem then reply . Thanks in advacne (4 Replies)
Discussion started by: tahir23
4 Replies

4. Shell Programming and Scripting

shell script for moving all the file from the same folder

Hi , I need a shell script which basicaly moves all the files from one folder say folder x to folder y and once they are moved to folder y a datetimestamp should be attached to there name for ex file a should be moved to y folder and renamed as a_20081015 (1 Reply)
Discussion started by: viv1
1 Replies

5. Shell Programming and Scripting

Shell Script for moving 3 days old file to Archive Folder

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)
Discussion started by: phani333
4 Replies

6. Shell Programming and Scripting

Execute shell script even if the first script fails

All, I executing a perl script and shell script from a master shell script. i will execute the perl script first and have to execute the shell script after the completion of perl execution. Below is the code i use for it, script_root='/dev/scripts' /usr/bin/perl -S $script_root/test.pl;... (5 Replies)
Discussion started by: vel4ever
5 Replies

7. Shell Programming and Scripting

How to exit from shell script if above condition fails?

HI cd ${back_home} if above back_home does not exist, then script shoul exit. Please let us know how to do that (7 Replies)
Discussion started by: buzzme
7 Replies

8. Shell Programming and Scripting

Shell Script for renaming and moving Files - Easy?

Hey guys, ive been working on this for about 2hrs now - without any solution. At first I need to say I dont have skills in linux bash scripting, but I tried to use some codesnippets and manuals from google. What I want to do: I have different folders including 2 different filestypes with... (15 Replies)
Discussion started by: peter1337
15 Replies

9. UNIX for Beginners Questions & Answers

Linux shell | how to exit a script if any command fails.

Hi, i am new here let me say HI for all. now i have a question please: i am sending one command to my machine to create 3 names. if one of the names exists then the box return error message that already have the name but will continue to create the rests. How i can break the command and... (7 Replies)
Discussion started by: Amiri
7 Replies

10. Shell Programming and Scripting

Array declared in shell script works for AIX but fails in Linux

Array declared in shell script works for AiX 6.1 and above but fails in Linux CentOS 7. I have the below code for Array in my shell script that runs fine on AiX systems. Note: on AiX it uses ksh shell while on Linux it uses non ksh shell. set -A filelist However, i now wish to use the... (3 Replies)
Discussion started by: mohtashims
3 Replies
uuto(1) 						      General Commands Manual							   uuto(1)

NAME
uuto, uupick - public UNIX system to UNIX system file copy SYNOPSIS
[options] source-files destination system] DESCRIPTION
sends source-files to destination. uses the facility to send files (see uucp(1)), while allowing the local system to control the file access. A source-file name is a path name on your machine. Destination has the form: where system is taken from a list of system names that knows about (see in uucp(1) manual entry). user is the login name of someone on the specified system. recognizes the following options: Copy the source file into the spool directory immediately, and send the copy. Send mail to the requester when the copy is complete. The files (or sub-trees if directories are specified) are sent to PUBDIR on system, where PUBDIR is the UUCP public directory Specifically the files are sent to PUBDIR The recipient is notified by electronic mail when the files arrive. accepts or rejects the files transmitted to the recipient. Specifically, searches PUBDIR for files destined for the user. For each entry (file or directory) found, the following message is printed on the standard output: file-name] dirname] then reads a line from the standard input to determine the disposition of the file: <new-line> Go on to next entry. Delete the entry. Move the entry to named directory dir (current directory is default). Note that, if the current working directory is desired for dir, do specify any parameter with A construction such as is erroneous, and results in loss of data. Same as except move all the files sent from system. Print the contents of the file. Stop. EOT (control-D) Same as Escape to the shell to execute command. Print a command summary. invoked with the option searches only the PUBDIR for files sent from system. WARNINGS
To send files that begin with a dot (such as the filename must contain a corresponding dot. For example: and are correct, whereas and are incorrect. FILES
PUBDIR public directory SEE ALSO
mail(1), uuclean(1M), uucp(1), uustat(1), uux(1). Tim O'Reilly and Grace Todino, O'Reilly & Associates, Inc. USA. Grace Todino and Dale Dougherty, O'Reilly & Associates, Inc. USA. STANDARDS CONFORMANCE
uuto(1)
All times are GMT -4. The time now is 07:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy