LinHES Forums http://forums.linhes.org/ |
|
delete old shows automatically, to save space http://forums.linhes.org/viewtopic.php?f=5&t=9575 |
Page 1 of 1 |
Author: | avocade [ Mon Apr 10, 2006 3:27 pm ] |
Post subject: | delete old shows automatically, to save space |
quick question: these shows made with myth2ipod clutter up my drive pretty good, and I have no automated way of removing them (say, like the way MythTV autoexpires its recordings). How could I add this to either crontab or to the script itself? possible? also, if possible, since I only use the ipod-converted shows (i.e. I don't watch the .nuv files) it would be great to just auto-delete the .nuv/.mpg files in /myth/tv when it's done converting to ipod. Edit: I tried running these scripts as cron jobs, but they don't seem to work...... 20 17 5,20 * * rm -rf 'ls /myth/ipodfeed/*.mp4* -1t | tail -20' 20 19 5,20 * * rm -rf 'ls /myth/ipodfeed/*.xml* -1t | tail -30' |
Author: | misterflibble [ Mon Apr 10, 2006 5:28 pm ] |
Post subject: | |
I can't remember the format for cron jobs, but I do know that rm -rf 'ls /myth/ipodfeed/*.mp4* won't work since it looks for the file named ls....mp4* Try rm -rf /myth/ipodfeed/*.mp4* instead |
Author: | tjc [ Mon Apr 10, 2006 7:42 pm ] |
Post subject: | |
Better still. Write a script that includes those commands and run it from your crontab. Remember anything you're going to run from cron or remotely should make minimal assumptions about the environment settings and use fullpaths whenever possible. Don't forget to chmod +x and include the right #! magic on the first line. |
Author: | avocade [ Tue Apr 11, 2006 3:20 am ] |
Post subject: | |
Thanks, but this command rm -rf /myth/ipodfeed/*.mp4* will remove all mp4-files. The one I looked for is one that deletes the 15 oldest files, which is what this command rm -rf 'ls /myth/ipodfeed/*.mp4* -1t | tail -20' is supposed to do. I found it with google, but when I run it it says something like "rm: lstat can't remove....". And it seems I can't pipe the 'ls | tail' into rm either... |
Author: | misterflibble [ Tue Apr 11, 2006 10:23 am ] |
Post subject: | |
Oh my mistake, I forgot about the 15 oldest thing You had it almost right: Code: rm `ls /myth/ipodfeed/*.mp4* -1t | tail -15`
Notice that the quotes surrounding the ls and tail commands are the backward quotes, not the regular ones (usually they're on the same key as the ~ above the tab key, but since you're from Sweden, I don't know if this is true for you). This makes the commands inside execute and the output be used by rm |
Author: | avocade [ Tue Apr 11, 2006 4:45 pm ] |
Post subject: | |
misterflibble wrote: Oh my mistake, I forgot about the 15 oldest thing
You had it almost right: Code: rm `ls /myth/ipodfeed/*.mp4* -1t | tail -15` Notice that the quotes surrounding the ls and tail commands are the backward quotes, not the regular ones (usually they're on the same key as the ~ above the tab key, but since you're from Sweden, I don't know if this is true for you). This makes the commands inside execute and the output be used by rm That's great, I'll try it ASAP. If I find those quotes.... Edit: Worked like a charm. Thanks! One change would be that, instead of deleting the 15 oldest files, you delete all the files older than 2 weeks or something. I'm trying to set this up for my folks so that it Just Works, and so the Mythboxen doesn't run out of space and goes all file-system-error:y on me - them... Could I simply adjust the ls command to give me files older than 14 days? |
Author: | tjc [ Tue Apr 11, 2006 7:01 pm ] |
Post subject: | |
The best way to do that is with the find command something like this: Code: find /myth/ipodfeed/ -name '*.mp4*' -mtime +14 -print0 | xargs -0 rm Please note that this is UTTERLY untested, and you should read the man page for find to make sure that it does wat you want. When testing commands like this drop the xargs part and use -ls rather than -print or -print0. Code: find /myth/ipodfeed/ -name '*.mp4*' -mtime +14 -ls
|
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |