HaLo2FrEeEk Posted August 14, 2008 Share Posted August 14, 2008 You've probably all seen my thread about deleting a file after 24 hours on the server, but I'd like to take it a step further and archive the old files for a week. So technically, I'd have the file on the server for a week and a day: 1 day in the main folder, then 1 week in the archive folder. The reason for this is so that the least amount possible is lost for my users. So I've read up abut ctime and mtime, and I'm still confused. will mtime change if I move the file to another directory? If I have the file in say... /images and I move it to /archive, will the mtime change to the time it was moved to /archive? If so, then I could change my delete command, which right now is this: /usr/bin/find /path/to/images -mtime +0 -exec rm {} \; to this: /usr/bin/find /path/to/images -mtime +0 -exec mv ../archive {} \; Right? Then I can add another cron that will be something like this: /usr/bin/find /path/to/archive -mtime +7 -exec rm {} \; If it's that easy, then I'll be happy, but I don't want to put into place yet in case it doesn't work and I mess something up. So, will this work? Thank you in advance, you guys were a huge help before, here's hoping I can get this working! Quote Link to comment Share on other sites More sharing options...
ignace Posted August 14, 2008 Share Posted August 14, 2008 try it! Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 15, 2008 Author Share Posted August 15, 2008 I hate trying something if I'm not 100% sure it'll work, and I only have pictures for less than a day right now, so it'll be a week before I would be able to test it. I just want to know if my theory is correct. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 16, 2008 Author Share Posted August 16, 2008 Ok, I ran the command: /usr/bin/find /home/halo2freeek/infectionist.com/misc/bungie_webcam/images/gifs -mtime +0 -exec mv /home/halo2freeek/infectionist.com/misc/bungie_webcam/archive/gifs {} \; And this is the error message I got: mv: cannot overwrite non-directory `/home/halo2freeek/infectionist.com/misc/bungie_webcam/images/gifs/1218760203.gif' with directory `/home/halo2freeek/infectionist.com/misc/bungie_webcam/archive/gifs' mv: cannot overwrite non-directory `/home/halo2freeek/infectionist.com/misc/bungie_webcam/images/gifs/1218760803.gif' with directory `/home/halo2freeek/infectionist.com/misc/bungie_webcam/archive/gifs' Why is that happening? I'm telling it to move the file to /home/halo2freeek/infectionist.com/misc/bungie_webcam/archive/gifs, why can't it? Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 16, 2008 Author Share Posted August 16, 2008 Bump, needs help with this, I promised people that I would keep a 7 day archive, I need to figure out how to do this. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 16, 2008 Author Share Posted August 16, 2008 bump. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted August 16, 2008 Share Posted August 16, 2008 dude stop bumping. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 17, 2008 Author Share Posted August 17, 2008 No, I can't figure this out on my own and it gets pushed to the bottom of the list if it doesn't get replied to quickly. I need an answer, everyone was so helpful with my last request, I just need someone to help me out with this, please. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 18, 2008 Author Share Posted August 18, 2008 Ok, just to reiterate what I've done already, so you don't think I'm being lazy and not trying to figure this out on my own: I started with the cron command to delete day old files from the folder: /usr/bin/find /home/halo2freeek/infectionist.com/misc/bungie_webcam/images -mtime +0 -exec rm {} \; But I decided I wanted to archive those files for a week after their one day was up, so I made a folder called "Archive" and tried this: /usr/bin/find /home/halo2freeek/infectionist.com/misc/bungie_webcam/images -mtime +0 -exec mv ../archive {} \; And that didn't work, so I tried this, thinking that the relative path was the problem: /usr/bin/find /home/halo2freeek/infectionist.com/misc/bungie_webcam/images -mtime +0 -exec mv /home/halo2freeek/infectionist.com/misc/bungie_webcam/archive {} \; Nothing, it gives me an error code: 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/' mv: cannot overwrite non-directory `/home/halo2freeek/infectionist.com/misc/bungie_webcam/images/1218760803.jpg' with directory `/home/halo2freeek/infectionist.com/misc/bungie_webcam/archive/' Now, I can see no reason why it shouldn't see the move command and move it over just fine, mv is the move command, I know that, and relative paths work, but an absolute path should be even better, so please, I'm asking you, I've already told people I'd have a 7 day archive up with a gallery of all the images, I need to be able to do this, please, help me figure out the problem. Thank you. 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.