Register
It is currently Wed Apr 23, 2014 8:48 pm

Need to download a file and delete it after 24 hours


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Feb 13, 2009 7:46 am   

Joined: Fri Feb 13, 2009 7:40 am
Posts: 1
Hi, i need to download a file but also i need it to be deleted after 24 hours.

Any idea?


Top
 Profile  
 PostPosted: Fri Feb 13, 2009 9:24 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
Use wget to get the file (if you know the url).
and use find /path/ -mtime +0 -name filename to find files older then 24 hours.

Ex.
Code:
# just for flashyness
function cleanup {
   path="/path/to/where/to/find/"
   pattern="filename.file"
   for i in $(find $path -mtime +0 -name "$pattern"); do
       rm $i
   done
}

# get file
wget http://url.to.site.com/filename.file
# Execute function to cleanup files older then 24h
cleanup


Best regards
Fredrik Eriksson


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP