SunQuest
           Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old October 15th, 2003, 05:07 PM
bcyde's Avatar
bcyde bcyde is offline
Me likey breadsticks...
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2003
Location: Los Angeles
Posts: 1,189 bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 1 h 12 m 57 sec
Reputation Power: 12
Send a message via AIM to bcyde Send a message via Yahoo to bcyde
Seeking a linux shell script for to compare last modified file time.

Not sure if I should've posted this in Linux or scripts, but I'm basically looking for a bash shell script that will be able to check for a files properties to see if it has been modified within a set amount of time. This is because where I'm hosting my site doesn't allow FTP so my webcam updates to my own linux server, and then I'm going to run a cron script that checks the files properties and if it's been updated in the last 5 minutes SCP to my website.

I've been trying to do this as a bash shell script however I'm having trouble finding either the right function to get the date properties or parsing text.

Right now I was approaching it by trying to do a stat -t on the file, however I have to either parse the output of stat or try and read it into an array variable.

I could get this done a whole lot easier, by just using PHP with wget in my cron, but I figure a bash script would be cleaner (less files) and would also be pretty simple if I just could find out the proper function/syntax.

-b
__________________
PostgreSQL, it's what's for dinner...

Reply With Quote
  #2  
Old October 16th, 2003, 12:23 PM
bcyde's Avatar
bcyde bcyde is offline
Me likey breadsticks...
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2003
Location: Los Angeles
Posts: 1,189 bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level)bcyde User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 1 h 12 m 57 sec
Reputation Power: 12
Send a message via AIM to bcyde Send a message via Yahoo to bcyde
I figured it out, if anyone ever needs something like this here it is for posterity's sake (I'm a newb in linux shell scripting so feel free to point and laugh:
PHP Code:
#
#Ghetto auto SCP script Bryan Encina 10-16-2003 
#
#Assumptions:    passwordless SCP has been setup via generation of private/public
#        keypair and insertion of pub key to webhost user's 
#        .ssh/authorized_keys file
#Intended Use:  uploading webcam image from linux server to another webhost
#        that does not support FTP (only SCP), probably of no use to anyone else
#Usage:        make an entry in your crontab to run as the user who's setup for passwordless scp
#        to run this script with the path to your webcam img as a 
#        command line arg        

#user settings edit the vars below
checkduration=300          #if current - timestamp is less than this we have a new file default to 5 minutes
remoteuser=myremoteuser    #user at remote host
mydomain=mydomain.com    #the domain/ip of your remote host
destpath=yourfile        #the path to your remote file

#do not edit below unless you know what you're doing, but if you did you 
#wouldn't be using this and you'd be writing your own wouldn't you?
localfile=$1

cur_timestamp
=`date +%s`
my_stat=`stat -t $localfile 2>/dev/nullread name size blocks unk uid gid dev inode links unk2 unk3 last_access last_mod last_change ioblock << ENDHERE
    
$(echo $my_stat)
ENDHERE

if [ $last_mod ]
then
    time_diff
=`expr $cur_timestamp - $last_mod`
    if [ 
$time_diff -lt $checkduration ]
    
then    
        
#echo This is a recent file
        
scp $localfile $remoteuser@$mydomain:$destpath
    fi
fi 

Reply With Quote
  #3  
Old January 8th, 2004, 08:15 AM
adesigno adesigno is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 1 adesigno User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
HI,

is there any ohter possibility to to see if a file has been modified within x minutes.

On Linux I use find -cmin but under HP-UX -cmin is not available.
Also stat -t is a good solution on Linux but again the comand is not available on HP-UX.

Is there anybody that kwows a solution under HP-UX to find out if a file has been changed in the last x minutes.

Thanks a lot
ad

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Seeking a linux shell script for to compare last modified file time.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway