View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 7 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Mon Apr 10, 2006 3:27 pm 
Offline
Joined: Sat Jun 18, 2005 7:47 am
Posts: 73
Location: Sweden
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'


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 10, 2006 5:28 pm 
Offline
Joined: Mon Aug 01, 2005 10:18 am
Posts: 84
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 10, 2006 7:42 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 3:20 am 
Offline
Joined: Sat Jun 18, 2005 7:47 am
Posts: 73
Location: Sweden
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...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 10:23 am 
Offline
Joined: Mon Aug 01, 2005 10:18 am
Posts: 84
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 4:45 pm 
Offline
Joined: Sat Jun 18, 2005 7:47 am
Posts: 73
Location: Sweden
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?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 7:01 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
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


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu