Sftp - 1 day older files count


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sftp - 1 day older files count
# 8  
Old 01-11-2013
Quote:
Originally Posted by vegasluxor
On local server we can use:
Code:
find <path> -type f -mtime +1

With ssh you can use
Code:
ssh user@hostname find <path> -type f -mtime +1

# 9  
Old 01-12-2013
Sftp - 1 day before files

hi, list the files in one file and run the below command.

dat=yesterday_date (if u want I will give the full command to get the yesterday's date)
Code:
grep "$dat" $file | wc -l

Above command will give the count of previous days files.

If you have any trouble to listing the files in one file, feel free to ask me.

---------- Post updated 01-12-13 at 12:06 AM ---------- Previous update was 01-11-13 at 05:56 AM ----------

Franklin,

Follow the below steps as it is...

Code:
dat=`date -d "-1 day" | awk '{print $2, $3}'`
 
BINCURL=/usr/local/bin/curl ( Change curl path according to your server)
PROXYPARM = if you have proxy please put mention here.
TMPLISTFILE = File name where you want to store the sftp list output
USER & PASSWORD= Put your credentials here
CLIENT_FTP_PROTOCOL= sftp
CLIENT_FTP_SERVER= your sftp server name
PORTPARM=port number
SUBDIRPARM= Exact path in sftp server
 
$BINCURL -k --disable-epsv -s $PROXYPARM -o $TMPLISTFILE 
  -u $CLIENT_FTP_USER:$CLIENT_FTP_PASSWORD
  $CLIENT_FTP_PROTOCOL://${CLIENT_FTP_SERVER}${PORTPARM}/${SUBDIRPARM} > /dev/null 2>&1

Now you can find the total sftp list in TMPLISTFILE file.

And execute the below command for yesterday's count

Code:
grep "$dat" $TMPLISTFILE | wc -l

Hope it is useful to you.

Last edited by Scott; 01-16-2013 at 08:25 AM.. Reason: Please use code tags for data and code samples...
# 10  
Old 01-16-2013
Hi,

I used "scp" on oracle linux 5.

Can you try this

find . -name "*" -mtime +1 -exec scp <may be u use port like -P portnumber> "{}" <remote_user>@<remote_host>:<directory>";"

for example

find . -name "*" -mtime +1 -exec scp -P 34000 "{}" remote_user@remote_system:/home/remote_user/ ";"

Last edited by Ozzy; 01-16-2013 at 08:53 AM.. Reason: correct code :)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Delete 5 days older files from sftp

As one of our requirement was to connect to remote Linux server through SFTP connection and delete some files which are older than 7 days. I used the below piece of code for that, SFTP_CONNECTION=`sftp user_id@host ... cd DESIRED_DIR; find /path/to/files* -mtime +5 -exec rm -rf {} \; bye... (2 Replies)
Discussion started by: ATWC
2 Replies

2. Shell Programming and Scripting

Delete 5 days older files from sftp

As one of our requirement was to connect to remote Linux server through SFTP connection and delete some files which are older than 7 days. I used the below piece of code for that, SFTP_CONNECTION=`sftp user_id@host ... cd DESIRED_DIR; find /path/to/files* -mtime +5 -exec rm -rf {} \;... (1 Reply)
Discussion started by: ATWC
1 Replies

3. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

4. Shell Programming and Scripting

Grep files older than 1 day

I thought that this would work for grep'ing files older than 1 day. ps -o etime,pid,user,args -e|awk '/^+-/'|sort -t- -n -k 1,1 |grep qdaemon |grep /usr/bin/ksh But, it is not grep'ing any of files (i.e. below) older than 1 day. d_prod 33757970 61999560 0 Oct 27 - 0:00... (8 Replies)
Discussion started by: Daniel Gate
8 Replies

5. Shell Programming and Scripting

Find processes older than 1 day

// AIX 6.1 I need to extract PIDs of ps -ef |grep /usr/lib/lpd/pio | awk '{print $2}' ps -ef |grep qdaemon |grep /usr/bin/ksh | awk '{print $2}' that are older than 1 day. I know find . -type f -mtime +1, but it doesn't work for PIDs. Please let me know how to get the PIDs older than... (1 Reply)
Discussion started by: Daniel Gate
1 Replies

6. Shell Programming and Scripting

How archive the older than 30 day files to another unix server

I need to archive the older than 30 day file to another uinx server.I have wrote the below uinx script. for LOOK_DIR in /TempFiles do for FILE in `find ${LOOK_DIR} -mtime -30 -exec ls {} \;` do echo ${FILE} >> file_list ## This file will have the list of files copied and... (12 Replies)
Discussion started by: murari83.ds
12 Replies

7. Shell Programming and Scripting

Command to Count the files which is Older than 3 months?

Hi Gurus the count of files in a particular Directory... ls -lrth | grep -c ^- can any one share the command to Count the files which is Older than 3 months So please help me out in this Thanks in Advance (2 Replies)
Discussion started by: SeenuGuddu
2 Replies

8. Shell Programming and Scripting

Find the number of files older than 1 day from a dir

Hello All, I need to write a script/command which can find out the number of .csv files residing in a directory older than 1 day. The output should come with datewise (means for each date how many files are there). I've this command, but this command gives the total number of files. It's... (10 Replies)
Discussion started by: NARESH1302
10 Replies

9. Shell Programming and Scripting

Deleting / finding files older than X days missess a day

Hi When trying to find and delete files which are, say, 1 day, the find command misses a day. Please refer the following example. xxxd$ find . -type f -ctime +1 -exec ls -ltr {} \; total 64 -rw-rw-r-- 1 oracle xxxd 81 Apr 30 11:25 ./ful_cfg_tmp_20080429_7.dat -rw-rw-r-- 1... (4 Replies)
Discussion started by: guruparan18
4 Replies

10. Shell Programming and Scripting

find files older than 30mins,count and send mail

Hi all, I wrote this script to find files older than time parameter, count the number of files, and send an email to me that some files are in a particular folder. For the particular path, the script should wait delay parameter before running again. For example, assuming the input file looks... (4 Replies)
Discussion started by: kayarsenal
4 Replies
Login or Register to Ask a Question