03-01-2011
Script to check for the newest file mutiple times a day and SCP it to another server.
Hi, I need a sample of a script that will check a specific directory multiple times throughout the day, and scp the newest file to another server.
Example: current file is misc_file.txt_02272011 (the last part is the date), once that has been secure copied, another one may come in later the same day named misc_file.txt_002272011A, which needs to be copied as well. The next day a new file will come in named misc_file.txt_02282011.
I'll probably rename the previous file to .DONE, or someting like that.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
We have data files that are ftp'd every morning to a SUN server. The file names are exactly the same except for that each has the date included in its name. I have to write script to do 2 things:
STEP 1) Verify that the file arrived in morning.
STEP 2) Compare the file size of the current... (3 Replies)
Discussion started by: rbknisely
3 Replies
2. Shell Programming and Scripting
Please forgive this I think rather basic question.
I have been away from UNIX for a very long time and am in need of some help.
I need to be able to check for the existance of a specific file name say 'file.dat' in a particular location
If the file exists then run a second process (at... (2 Replies)
Discussion started by: JohnCrump
2 Replies
3. Shell Programming and Scripting
Hi all,
I am new to this forum,and it has been really a great pleasure to be a part of this forum:)
well,i m trying to write a shell script where i m transfering a set of files from other server to my own server.
for this i m using scp... (1 Reply)
Discussion started by: prasson_ibm
1 Replies
4. Shell Programming and Scripting
Hi,
The tag can occur multiple times.
I want to remove entire <SeqNum>..</SeqNum> from each line, regardless the values with in this tag. for each line value inside these tags could be different. So please suggest how to do this.
Note: Each profile information is in one line.
... (2 Replies)
Discussion started by: Anusha_Reddy
2 Replies
5. Shell Programming and Scripting
Hi,
I would like to write a script that checks if a file ('counter') was modified the previous day, if so erase its contents and write 00000000 into it.
For e.g. if the file 'counter' was last modified at 11.30pm on 24th May and the script runs at 12.15am of 25th May, it should erase it's... (1 Reply)
Discussion started by: hegdepras
1 Replies
6. Shell Programming and Scripting
Hi,
I have a file with extension xml. So i need to search for this file and sftp.
This script has to run from 8.00am to 8.00pm and during this when ever a file with *.xml exists in a particular directory , it has to sftp that file.
How can i make script check for this file through out the... (2 Replies)
Discussion started by: krishna_gnv
2 Replies
7. UNIX for Dummies Questions & Answers
Hi all,
So I am on server 1, and I want to grab the newest file from a particular directory on server 2, and place this in a directory on server 1.
I am trying to use: ls -tr | tail -1
This works, and gets me the newest file in a particular directory. Using svn `ls -tr | tail -1` etc I... (1 Reply)
Discussion started by: Lexx87
1 Replies
8. UNIX for Dummies Questions & Answers
Hi Team ,
Is there a way I can check to see if the same file say , test.dat exists multiple times in the directory path ?
Please help.
Thanks
Megha (5 Replies)
Discussion started by: megha2525
5 Replies
9. Shell Programming and Scripting
Dears does anybody know how to check the file size on server A and server B before and after scp using KSH. Script should be on server A.
I will be using it for the below mentioned scenario:
I have written a code to fetch files from server A, move it onto server B compress it and save it on... (2 Replies)
Discussion started by: BrownBob
2 Replies
10. Shell Programming and Scripting
How to check the day name,is it saturday in bash shell script.
If dayname = saturday then
run the full load
else
run just the incremental loads
end if
Thank you very much for the helpful information. (4 Replies)
Discussion started by: cplusplus1
4 Replies
ypxfr(1M) System Administration Commands ypxfr(1M)
NAME
ypxfr, ypxfr_1perday, ypxfr_1perhour, ypxfr_2perday - transfer NIS map from a NIS server to host
SYNOPSIS
/usr/lib/netsvc/yp/ypxfr [-c] [-f] [ -C tid prog server] [-d ypdomain] [-h host] [-s ypdomain] mapname
DESCRIPTION
The ypxfr command moves an NIS map in the default domain for the local host to the local host by making use of normal NIS services. It
creates a temporary map in the directory /var/yp/ypdomain (this directory must already exist; ypdomain is the default domain for the local
host), fills it by enumerating the map's entries, fetches the map parameters (master and order number), and loads them. It then deletes any
old versions of the map and moves the temporary map to the real name.
If run interactively, ypxfr writes its output to the terminal. However, if it is started without a controlling terminal, and if the log
file /var/yp/ypxfr.log exists, it appends all its output to that file. Since ypxfr is most often run from the privileged user's crontab
file, or by ypserv, the log file can retain a record of what was attempted, and what the results were.
For consistency between servers, ypxfr should be run periodically for every map in the NIS data base. Different maps change at different
rates: a map might not change for months at a time, for instance, and can therefore be checked only once a day. Some maps might change sev-
eral times per day. In such a case, you might want to check hourly for updates. A crontab(1) entry can be used to automatically perform
periodic updates. Rather than having a separate crontab entry for each map, you can group commands to update several maps in a shell
script. Examples (mnemonically named) are in /usr/sbin/yp: ypxfr_1perday, ypxfr_2perday, and ypxfr_1perhour.
Refer to ypfiles(4) for an overview of the NIS name service.
OPTIONS
-c Do not send a "Clear current map" request to the local ypserv process. Use this flag if ypserv is not running
locally at the time you are running ypxfr. Otherwise, ypxfr complains that it cannot communicate with the local
ypserv, and the transfer fails.
-f Force the transfer to occur even if the version at the master is not more recent than the local version.
-C tid prog server This option is for use only by ypserv. When ypserv starts ypxfr, it specifies that ypxfr should call back a yppush
process at the host server, registered as program number prog, and waiting for a response to transaction tid.
-d ypdomain Specify a domain other than the default domain.
-h host Get the map from host, regardless of the master. If host is not specified, ypxfr asks the NIS service for the name
of the master, and tries to get the map from there. host must be a valid host name.
-s ypdomain Specify a source domain from which to transfer a map that should be the same across domains.
FILES
/var/yp/ypxfr.log Log file
/usr/lib/netsvc/yp/ypxfr_1perday Script to run one transfer per day, for use with cron(1M)
/usr/lib/netsvc/yp/ypxfr_2perday Script to run two transfer per day, for use with cron(1M)
/usr/lib/netsvc/yp/ypxfr_1perhour Script for hourly transfers of volatile maps
/var/yp/ypdomain NIS domain
/usr/spool/cron/crontabs/root Privileged user's crontab file
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
ypxfr Only
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWnisu |
+-----------------------------+-----------------------------+
ypxfr_1perday, ypxfr_1perhour, and ypxfr_2perday
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWypu |
+-----------------------------+-----------------------------+
SEE ALSO
crontab(1), cron(1M), ypinit(1M), yppush(1M), ypserv(1M), ypfiles(4), attributes(5)
SunOS 5.10 11 Mar 1998 ypxfr(1M)