Operating System - HP-UX
1753727 Members
4623 Online
108799 Solutions
New Discussion

Need script to move critical files on the same server

 
Vishal_1980
Regular Advisor

Need script to move critical files on the same server

Hello Experts,

 

I am having a production server on to which few files are generated on the path /usr/sap/STV/CRDVMGP01/logs.

 

On that path there are 2 files respectively : report_20140729 & report_20140730...

 

However i need to move the file for the yesterday to a /dump directory  as the size of the file is aprox 25 gig.

Doing that i need to keep todays file as it is on the path , just need to move yesterdays file to dump directory..

 

Thanks & have a great day ahead...

Vishal

2 REPLIES 2
Patrick Wallek
Honored Contributor

Re: Need script to move critical files on the same server

Are you saying that you need to just move a single file from one directory to another just once?  Or do you need to move the file for the previous day every day?

 

If you just need to move a file once, then just use the mv command.

 

If you need to move the previous days file every day that is a bit more difficult.

 

This short script should move the previous days file to the dump directory:

 

# cat mv_file.sh

#!/usr/bin/sh

YESTERDAY=$(perl -e 'use POSIX;print strftime "%Y%m%d",localtime time-86400;')

cd /usr/sap/STV/CRDVMGP01/logs
mv report_${YESTERDAY} /dump

 

 

Vishal_1980
Regular Advisor

Re: Need script to move critical files on the same server

Hello Patric,

 

Thanks for the reply .

 

do you need to move the file for the previous day every day? Yes this is what i want...

 

I will check with the script & get back to you.

Thnaks once again

 

 

Have a great day ahead..

 

Regards

Vishal