HaLo2FrEeEk Posted August 19, 2008 Share Posted August 19, 2008 I tried to make the title descriptive enough. Basically, I have a php script set up to transfer a file from another server every 10 minutes (the file changes), and save it with a timestamp. I havea cron set up to delete the images after 1 day, but I'd like to archive them for a week then delete them. Is there a way to do this? I've tried a few cron commands like: /usr/bin/find /home/halo2freeek/infectionist.com/misc/bungie_webcam/images -mtime +0 -exec rm {} \; Which returned something about not being able to find the directory ../archive. I thought, "ok, it doesn't like the relative path", so I tried: /usr/bin/find /home/halo2freeek/infectionist.com/misc/bungie_webcam/images -mtime +0 -exec mv /home/halo2freeek/infectionist.com/misc/bungie_webcam/archive {} \; Which returned: mv: cannot overwrite non-directory `/home/halo2freeek/infectionist.com/misc/bungie_webcam/images/1218760203.jpg' with directory `/home/halo2freeek/infectionist.com/misc/bungie_webcam/archive/' Now, I'm no expert, but I'm pretty sure I just told it to move the file that it found to the archive folder, not overwrite anything. Is there any way to make this work? I DO have a reason that I want the 7 day archive to be in a different folder. The files I'm transferring are images, and I'm animating a day's worth of the images (those in the images folder) in a dynamically generated animated gif, I don't want to animate 7 days though, but I want them to be viewable by people. Can someone help me out? Quote Link to comment Share on other sites More sharing options...
trq Posted August 19, 2008 Share Posted August 19, 2008 Your missing a backslash. /usr/bin/find /home/halo2freeek/infectionist.com/misc/bungie_webcam/images -mtime +0 -exec mv /home/halo2freeek/infectionist.com/misc/bungie_webcam/archive/ {} \; Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 19, 2008 Author Share Posted August 19, 2008 That didn't work, it's still giving me the overwrite error. It's saying I can't overwrite non-directory (filename) with the archive folder, like I'm trying to move the folder to the picture, and not the other way around... And in addition to this, I have a folder called gifs inside the regular images folder. When I run the command to look in the images folder, it searches subfolders, and will thus move the gif to the root archive folder, I want it moved to archive/gifs. To do this, would I simply run the command first looking in the gifs folder, then looking in the images folder, that way the gifs get moved first? Quote Link to comment Share on other sites More sharing options...
trq Posted August 19, 2008 Share Posted August 19, 2008 Sorry, I should look closer. /usr/bin/find /home/halo2freeek/infectionist.com/misc/bungie_webcam/images -mtime +0 -exec mv {} /home/halo2freeek/infectionist.com/misc/bungie_webcam/archive/ \; Quote Link to comment Share on other sites More sharing options...
trq Posted August 19, 2008 Share Posted August 19, 2008 Oh, and to answer this.... To do this, would I simply run the command first looking in the gifs folder, then looking in the images folder, that way the gifs get moved first? Yes, that would probably be the simplest solution. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 20, 2008 Author Share Posted August 20, 2008 IT WORKED!!! Yay, thank you, now all I need to do is change the 24 hour delete to a 7 day delete from the archive folder. You rock. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 21, 2008 Author Share Posted August 21, 2008 Ok, turns out that though this DID work, it seems to want to move some of the gifs to the main images folder, instead of the gifs folder. Now, I could seperate the two, have gifs and images bee in one folder, and not gifs being a subdirectory of images, but is there a way to tell find to NOT look in subdirectories? That would simplify things a bit. I don't know why it happened, but when I looked today, there were 2 gifs in the wrong folder. I can't have that happen consistently, so, is there a way to make it not look in the subdirectories of the folder it's searching? Quote Link to comment Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 is there a way to tell find to NOT look in subdirectories? Yeah, the -maxdepth option. /usr/bin/find /home/halo2freeek/infectionist.com/misc/bungie_webcam/images -maxdepth 1 -mtime +0 -exec mv {} /home/halo2freeek/infectionist.com/misc/bungie_webcam/archive/ \; Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 21, 2008 Author Share Posted August 21, 2008 You are an amazing person. I would kiss you if lips could go through the internetz. Lol, thank you, you've a huge help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.