Jump to content

Recommended Posts

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!

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?

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.