Archive for the ‘How To / Tips’ Category

Running Shells as Cronjobs with CakePHP on Ubuntu

I found it a little tricky to get my CakePHP shell to run as a cronjob on my Ubuntu server, so I thought I’d do a little write up on how I ended up doing it. First off, I’m using Cakephp 2.0 and Ubuntu 10.04 LTS. I’m not a linux expert, which is probably why I had issues figuring it out in the first place.

The first step is to have a shell script you want to run. For the following example, I have a shell called HelloShell.php located in /var/www/example.com/public_html/app/Console/Command/ . See Cake’s Console and Shells guide for more details on writing shell scripts.

I use the cake console pretty often for the bake functionality, so I always add a path to it so I can access from any directory.

To do this, I edited .profile in my home directory and added this line at the bottom to the location of my cake console:

export PATH=/var/www/example.com/public_html/lib/Cake/Console:$PATH

I believe you have to logout and back in for it to take effect.

Now type: cake -app /var/www/example.com/public_html/app hello

If your path is set properly, you should see the output of your HelloShell.php script. Now we’re good to go to setup the cronjob.

Type crontab -e to open up the editor.

Here are the settings I used to run my cronjob every 30 minutes:

*/30 * * * * /var/www/example.com/public_html/lib/Cake/Console/cake -app “/var/www/example.com/public_html/app” hello

You can also output to a log file with various levels of verbosity:

*/30 * * * * /var/www/example.com/public_html/lib/Cake/Console/cake -app “/var/www/example.com/public_html/app” hello –quiet >> /home/myusername/hello_cron.log

Hope this helps someone!

Installing an aftermarket stereo in a Volkswagen Beetle

I recently installed a new aftermarket stereo in my 1999 Volkswagen Beetle. I was kind of forced into getting a new radio because I took my car in to a shop to diagnose a battery drain and they ended up cracking my factory radio when they pulled it out.

I have no real experience working with cars, and the install definitely took a lot longer than expected, but I think this is a task that most people can handle. My install was complicated by the fact that the shop that diagnosed my battery drain also removed the fuse to the radio (fuse 42, fyi) and didn’t tell me about it.

I ordered most of the parts I needed off of Amazon.

The stereo I bought was the Sony Xplod CDXGT55UIW. It has both USB connectivity with iPhone support and an AUX port for connecting anything else. It definitely beats the tape deck in my old radio.

Here’s the full list of items I needed:
(more…)