• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 853
  • Last Modified:

Script to check the time stamp of a file and then move it

I'm looking for a script that will monitor a directory and move any file that has been sitting in that directory for more than 15 seconds into another directory. Shell script or perl are welcome.

0
2xdafun
Asked:
2xdafun
1 Solution
 
ozoCommented:
perl -e 'while( sleep 1 ){ $^T=time; rename $_,"/another/directory/$_" or warn "$_ $!" for grep -f && -M > 15/(60*60*24), <*> }'
0
 
ravenplCommented:
ozo: You aware that 'sleep 1' in fact may fail to sleep 1 second? In such case it returns 0 :(
while(1) { sleep 1; ... # is somehow safer... Or
while(sleep 1,1) {...
0
 
2xdafunAuthor Commented:
thanks it works well.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now