Comparison of timestamp on ftp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comparison of timestamp on ftp
# 1  
Old 08-11-2012
[SOLVED] Comparison of timestamp on ftp

Hello

Need help with shell script

There is are files on my ftp. They overwriting every hour from other places.

Code:
ls -la /home/ftp/
-rw-r--r--  1 ftp nogroup    2296 2012-08-11 12:59 G1.zip
-rw-r--r--  1 ftp nogroup    6676 2012-08-11 13:00 KRT1.zip
-rw-r--r--  1 ftp nogroup    5169 2012-08-11 13:00 N1.zip
-rw-r--r--  1 ftp nogroup     634 2012-08-11 13:05 ND1.zip
-rw-r--r--  1 ftp nogroup    5410 2012-08-11 13:00 P1.zip
-rw-r--r--  1 ftp nogroup   16216 2012-08-11 13:00 U1.zip

Need to control time of overwriting and if file is updated too late then mail to root.

This script are working, but it not display filename.

Code:
!/bin/bash
if [[ $(find /home/ftp/*1.zip -mmin +20) ]]; then
   mail -s "ALARM" root
fi


Last edited by ck80; 08-13-2012 at 05:23 AM.. Reason: Please use code tags
# 2  
Old 08-11-2012
Please use find correctly: find /home/ftp -iname \*.zip ...
Don't expect any output from find inside the conditional expression.
find will return exit code 0 even if no files were found, so check your logics.
# 3  
Old 08-11-2012
You probably mean something like this:
Code:
#!/bin/bash
find /home/ftp -type f - name \*1\.zip -mmin +20 | while read filename
do
       echo "FTP file than 20 mins: ${filename}"|mail -s "ALARM" root
done

There are several things wrong with the original script apart from the strange find command.
The leading hash character on the shebang line is missing.
There is no piped input to the mail command (it would have failed).
# 4  
Old 08-13-2012
methyl

Thanks, it is that what i need!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To check timestamp in logfile and display lines upto 3 hours before current timestamp

Hi Friends, I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only I can get the... (12 Replies)
Discussion started by: srkmish
12 Replies

2. Shell Programming and Scripting

Comparison of a timestamp and mtime of a file

Hi, I am a beginner in shell scripting. Could any one help me out for below requirement. Its bit urgent. Problem scenario: 1) I have a predefined timestamp (Ex. 2011-03-010 10:10:20) 2) And I have files in a directory starting with 'a' (Ex. a_123.txt, a_124.txt) Expected solution: I... (1 Reply)
Discussion started by: itzsamz
1 Replies

3. Shell Programming and Scripting

preserving the timestamp of a file when copied from remote server to local server using ftp

Hi, I need to copy few files from remote server to local server. I write a shell script to connect to the remote server using ftp and go to that path. Now i need to copy those files in the remote directory to my local server with the timestamp of all those files shouldnt be changed. ... (5 Replies)
Discussion started by: arunkumarmc
5 Replies

4. Shell Programming and Scripting

FTP timestamp

Hi, I am searching for a way to change the display format of the timestamp from an FTP server. From a SOLARIS 9 server (ksh) I am connecting with a shell script using Ncftp to an FTP remote server. This script is making a list of available files on that FTP server. All files are listed with... (0 Replies)
Discussion started by: Aswex
0 Replies

5. UNIX for Dummies Questions & Answers

Timestamp comparison

How do I compare 2 timestamps (ie... if 2008-02-13 10:48:58.502075 gt 2008-12-15 16:00:00.000000) (4 Replies)
Discussion started by: auzark
4 Replies

6. Shell Programming and Scripting

Timestamp comparison of 2 files present in 2 different servers

Hi, I have 2 different log servers and logs are stored in both of them at varied times. Those servers have same files stored at different times. I want to retrieve the latest of the log files that are stored inthe servers. Say "file.log" is present on both servers, i want to check which of it is... (3 Replies)
Discussion started by: goutham4u
3 Replies

7. Shell Programming and Scripting

Timestamp comparison

Hi all, below is my sample log file 02.20.38 .CASH_I_0069 RPM_RUN_DISTRIBUTION RPM_RUN_DISTRIBUTION 0001 1987 Started at 02.19.11 at node IEREDS17, Pid = 00492972 02.50.39 .CASH_I_0054 RPM_RUN_DISTRIBUTION RPM_RUN_DISTRIBUTION 0001 1987 Completed at 02.49.13, code: 00000000 at node IEREDS17,... (1 Reply)
Discussion started by: zainravi
1 Replies

8. UNIX for Advanced & Expert Users

FTP from windows to Unix maintaining timestamp

Hi, Is it possible to Ftp the files from Windows to Unix while maintaining their timestamp Gaurav (1 Reply)
Discussion started by: gauravgoel
1 Replies

9. Shell Programming and Scripting

ftp - get file and keep original timestamp?

Can you ftp (get) a file from another server and keep the timestamp on the file that is on the other server? ie. server1 server2 - Mar 12 12:30 /filename1 On Mar 15 at 13:00 server1 ftp to server2 and get /filename1 I want the file filename1 to have the date (Mar 12 12:30) on the file... (2 Replies)
Discussion started by: frustrated1
2 Replies

10. UNIX for Dummies Questions & Answers

ftp timestamp

I have written a basic script to ftp files from a local machine to a remote one and put it into a crontab to automate the process as the directory has more files added to it. I also have a cron which periodically removes files from the local directory to stop the filesystem from becoming full.... (4 Replies)
Discussion started by: Henrik
4 Replies
Login or Register to Ask a Question