Archive for the ‘Cron’ Tag

Ubuntu 9.10 serving the PS3… pt 4

Ubuntu 9.10 serving the PS3 and everything involved… pt 1 : MediaTomb
Ubuntu 9.10 serving the PS3 and everything involved… pt 2 : HandBrake
Ubuntu 9.10 serving the PS3 and everything involved… pt 3 : Mashpodder
Ubuntu 9.10 serving the PS3 and everything involved… pt 4 : cron

So far I have Mediatomb installed and serving media to my PS3. I’m using Handbrake to rip DVD’s that I own and serving those mp4’s to the PS3 via mediatomb. I am downloading videocasts from the Internet via mashpodder and serving those files to the PS3 via mediatomb. Now I want to automate the downloading of those videocasts and the deletion of them after a week or so. For that we need cron… or crontab.

With cron, I’m going to automatically run mashpodder in the middle of the night and delete the old files that I have been downloading into those Audio and Video folders.

So open a terminal and add some cron jobs. At the commandline type:
$ crontab -e

Now you need to know the path to the mashpodder.sh script. My path is mashpodder-svn23/mashpodder.sh .
Now how to set it up or write it in our cron tab file. The format is:
* * * * * [COMMAND]
1st * – Min (00-59)
2nd * – Hour (00-23)
3rd * – Day of the month (00-31)
4th * – Month (01-12)
5th * – Day of the week ( 01-07)

Example:
00 03 * * * [command] Would be an entry to run a script every night at 3am.

My mashpodder entry looks like this:
30 03 * * * mashpodder-svn23/mashpodder.sh
It runs at 3:30am every night.
If i wanted it to run every Sunday at 3:30am, it would look like this:
35 03 * * 07 mashpodder-svn23/mashpodder.sh
It seems that the week starts on a Monday in cronland. I think we get the point. Experiment, play around with it.

I have mashpodder putting those video/audio files in these directories.
/home/terry/podcasts/Audio
/home/terry/podcasts/Video

I want to delete my videocasts after 10 days and my audiocasts after 180 days. I like to keep the audio around a little longer. I like to be file specific. My ogg file delete entry looks like this.
/home/terry/podcasts/Audio -name '*.ogg' -mtime +180 -exec rm -r {} \;
Now add specific times to delete these files. I use the same timing scheme that I used to run mashpodder.
I had to hunt around for the right delete command. The one I’m using works and is specific. It is also recursive, meaning it hits all subfolders. It will leave all other files alone. I know this is a bit confusing… at least it was to me but I got it hammered out and working. My crontab file looks like this:

I didn’t have to specify the Audio or Video folders in the delete commands. During the hunt for the correct delete command I had commands that would delete everything… even the folders themselves. The above commands do not do that. They are specific. I just left the Audio and Video folder part in there. My current crontab file is >here<.

Lots of good information here. Command scheduling with cron.

That’s it. I just let that machine run 24/7 and it does it’s thing. I fire up the PS3 on a daily basis to see what shows up. Like I said in the other posts, I’ll be re-doing/writing this all over again when the next Ubuntu LTS comes out. Maybe then I can document the whole process a little better. This was an experiment that snowballed and worked out well… for me anyway.

Advertisements

Ubuntu 9.10 serving the PS3… pt 1

Ubuntu 9.10 serving the PS3 and everything involved… pt 1 : MediaTomb
Ubuntu 9.10 serving the PS3 and everything involved… pt 2 : HandBrake
Ubuntu 9.10 serving the PS3 and everything involved… pt 3 : Mashpodder
Ubuntu 9.10 serving the PS3 and everything involved… pt 4 : cron

A PS3 for Christmas this year?… Lets get started. My original plan was to just feed some movies from a server/PC in my basement to the PS3 but things have changed. This will be a multiple part series so I’ll do the best I can to explain it. I’m doing this for my benefit, so I can set the whole thing up again once the next Ubuntu LTS comes out. If I can do this, most anyone else should be able to do this.

Parties involved:
PS3
Ubuntu 9.10
MediaTomb
HandBrake
Mashpodder
crontab
A couple of bash scripts

So in pt 1, I’ll be installing and setting up MediaTomb.

The PC involved/Hardware:
MB: Epox: EP 8RDA3+ Pro
CPU: AMD Athlon XP 2400+ (2Ghz)
Ram: 1.5 Gig
Video Card: Nvidia GeForce 4 Ti 4200

Installed from synaptic:(make sure these are installed)
mediatomb 0.12.0
mediatomb-common
mediatomb-daemon
vlc
ffmpeg
ffmpegthumbnailer

The Idea here is to have Mediatomb serve up some video to my PS3.
The OS on the PC is Ubuntu 9.10 . I installed MediaTomb right from Synaptic. The version in the repo’s is fine. Once installed, go to Applications > Sound_&_Video > MediaTomb. That will launch MediaTomb in your default browser(Firefox). It should look something like this:

Now you need to add which folders you want Mediatomb to scan/serve. At the top of the Mediatomb page you have Database and Filesystem. Click on Filesystem. Now if you have specific folders that you have your media in(video/audio) then specify each folder. Lets say you want to scan the video folder in your home directory. Then under Filesystem, click home > Your_user_name > videos.

Now to start scanning that folder, you click on the plus sign with the little arrows going around it. It’s in the upper right corner of the MediaTomb page.You will now get this page:

I have selected
Scan Mode: Timed – I want it to scan in specific intervals.
Scan Level: Full – I want a full scan.
Recursive: Checked – I want it to scan all subfolders.
Include hidden files/directories: Checked – Yes I want it too.
Scan Interval (in seconds): 1800(default-30min)

Do this for each folder that you want scanned. Now you should be set. If your MediaTomb and PS3 are plugged into the same network and MediaTomb is running, the PS3 will see it and display your Video folder and it’s supported contents. Look around on the PS3 menu’s under Video. You’ll see the MT icon.

Next set up your config.xml file. The location of that file is:
etc/mediatomb/config.xml
I used gedit to open and edit the file. Type at the commandline:
$ sudo gedit /etc/mediatomb/config.xml
Read through the file. I added ogg support because the PS3 does not support ogg. I left comments in my file above the 2 changes I made for the ogg addition. Also for ogg support, install VLC. It’s involved in the transcoding. VLC is in the repo’s. And turn on transcoding. The transcoding change is also in red.

For preview/thumbnail support, enable ffmpegthumbnailer. Enabling ffmpegthumbnailer is also in red. Then install ffmpegthumbnailer if you haven’t already. I installed it using synaptic.

This is my current config.xml file. All my changes/additions are commented and/or in red. I was going to set up MediaTomb to auto start on start up but I appears that it does that automatically. Maybe because I also installed mediatomb-daemon. I’ve done nothing else make it do this… but I like it.

Part 2 will cover converting DVD’s with Handbrake and the file format for the PS3.

More on the way… I just have to remember what I did. I will rewrite this whole thing on the next install. This install was more of an experiment that worked.

*A little bit of confusion*
If you haven’t noticed, there are two different locations for the config.xml file. One is in your home directory. It’s hidden:
home/your_user_name/.mediatomb/config.xml
The other location is:
etc/mediatomb/.config.xml
The version that I have installed uses the config.xml file in the etc/mediatomb location. This is also the config.xml file that is used during the auto start when Ubuntu boots. If you open MediaTomb from the command line, The config.xml file in your home directory is used. I’m not using that one. So, just open MediaTomb from the drop down menus and edit the config.xml file located at etc/mediatomb/config.xml and everything will be fine.

* I’m sure I’ve missed something. I’ll add them in and fix my spelling and grammar errors as I go.*

Update: This auto start thing isn’t 100%. I’ve had to reboot on more than one occasion to get it to start on it’s own. I’ll have to look into it more.