Linux Cron Job Tutorial: running a .php file

Comments 3 Standard

All of my database driven games use PHP as a scripting language which is my favorite scripting language by far (okay I’m biased, I’ve been using it for almost 9 years now).

In order to propagate changes each day I setup a cron job, or a scheduled script that will run a certain times of the day. In a nutshell this updates all of the underlying game structure so pets get older, shows automatically run, so forth and so on.

Accessing the Cron

Although you can edit the cron file directly (var/spool/cron/crontabs)  it’s easier to use the crontab command and let it do most of the work for you. Open a shell and type the following command. If you’re not a root user you’ll need to use sudo before these commands (and have super user permissions).

crontab -e

Editing The Cron

The syntax for the cron jobs you’ll be adding to this file is:

minute hour day month dayoftheweek /path/to/script

Minute is 0 – 59

Hour is on a 24 hour clock (0 – 23). With military time you subtract 12 from the number to get pm values. For instance take 15 and subtract 12 and you get 3pm. Everything earlier than 12 is am. The only exception are 0 and 12. 0 is midnight and 12 is noon.

Day is 1 – 31

Month is 1 – 12

Day of the week is 0 – 7 where Sunday is 0 or 7

Now to the good part, some examples. Let’s run a file at exactly midnight every day:

0 0 * * * /path/to/file

The asterisks indicate that this script will run every day. If we want to run the file at 12:15 midnight:

15 0 * * * /path/to/file

Let’s run a script on the 30th of the month at 2:45pm:

45 14 30 * * /path/to/file

Now I only want to run this script on October 31st every month every 25 minutes:

25 * 31 10  * /path/to/file

Last but not least I want to run this file every Tuesday at Midnight in March every 10 minutes:

10 * * 3 2 /path/to/file

My only word of caution is running scripts every x number of minutes every single day in small intervals (ie * * * * *  or 5 * * * *). This will eat up your CPU and end up locking out all of your other processes.

Emailing Cron Results

By default the cron is setup to email itself to the server every night. You can change which email each cron goes to by putting the following on the line before the cron:

0 14 30 * * /path/to/file/

Turning Off Cron Emailing

Sometimes having an email sent to you for some mundane script just wastes space in your inbox. That’s okay, you can turn the email feature off also:

5 20 * * * /path/to/script >/dev/null 2>&1

Setting Up A .php Cron File Through the PHP Interpreter

Replace the path to your php interpreter shown in blue below. Follow that by the -q option and the location of the .php file you’d like to run.

0 0 * * * /usr/local/bin/php -q /path/to/file.php

Running A .php File By Accessing It Online

If you’re accessing databases or includes in your .php file then you probably want to run the file as if you were viewing it on the internet from the domain name. You can use the curl command to do that in place of calling the php interpreter:

0 0 * * * curl /path/to/file.php


Hah, sorry I’m human and not a Linux guru: x | x

Video Game References: 3D Models, Degrees, Associations & Other Useful Links

Leave a comment Standard

I find that I visit so many different sites I can’t keep them straight and I can’t remember to update my delicious account. So I started adding them as resources on my main website when I found one I liked or wanted to go back to someday in the future. Here’s a list you may want to check them out for yourself. I’ve added my own comments and knowledge thrown into the mix:

Game Engines

Crystal Space 3D

Dark GDK

G3D Engine – good tool libraries, large free model collections

jMonkey Engine


Torque Engine – popular with independent developers

Unreal Engine – it’s a classic… now available for free.

MMO Specific

Unity 3D – in browser 3D MMO games, quickly gaining popularity as an engine. Has iPhone and Wii capabilities.

Big World Technology

Byond – not really an engine so much as a point and click game maker

Hero Engine

Irrlicht – i really like this one, runs fast, lightweight, nice toolset. Free. Showcase includes


Ogre 3D – i found this one to be way too complicated and not very well planned out. API was hard to use and understand if you want something you can just jump into and start programming.

Realm Crafter

Flash Specific

SmartFoxServer – Specifically for Flash MMOs.  I’ve chosen this one for an MMO I have in production. Free for up to 20 users, license required for 100, 500, and unlimited users ($300 – $3,000 dollars). Showcase games include Club Penguin, Atlantas and facebook’s app YoVille, and Build-a-Bear Workshop.

Red5 Server – Completely open source and free. If you’re looking to build on your own functionality this one is for you

Electro Server – Haven’t had a chance to play around with this one but it has a free 25 user version. Licenses for up to 500 – 200,000 users ($700 to $4,500+) — no unlimited license that I could find.  Showcase games include WebKinz, Nickeldeon and Barbie Let’s Chat.

3D Models

3D Cafe

3D Links

3D M3

3D Revolution

TurboSquid – largest collection of models made in Maya


Quality 3D

Poitra – expensive but nice stuff

Exchange 3D


Archive 3D – all free models

3D Extras – free models

Amazing 3D

3D Software

Maya – industry leader, costs a fortune though

3Ds Max – also an industry leader but cheaper than Maya. Owned by the same company.

Blender – free, can integrate python and lua scripting. Good support community, so-so documentation.

Drawing & Art Software

Photoshop -leading graphic art software, if you don’t have this you might as well quit now…

Painter – exclusively for people drawing with tablets

Gimp – essentially a free version of photoshop


ECA – Electronic Consumers Association

ESA – Electronic Software Association

ESRB – Entertainment Software Rating Board

IGDA – International Game Developers Association


Geninne – artist in Mexico, I want her on one of my projects one day

Creative Thursday – artists post to a new topic every thursday, great way to find a diamond in the rough

Illustration Friday – same as Creative Thursday with a bigger following

Simon Reeves – freelance 3D artist. Has done several commercials so I doubt he’s cheap.

Sarah J How – worked with her on graphics for one of my pet games. Highly recommended. She was a texture/character artists for Deep Red Games, looks like she’s running her own studio now. – tons of various artists. As a last resort you can probably find someone here.

Website Optimization & Usability Tools

Comments 2 Standard

Thanks to here’s a list of tools you can use to cleanup and optimize your website:

HTML Validation –

CSS Validation –

Link Validation –

Readability –

Color Contrast – and

SEO Keywords –

Colorblindness Simulator –

Image Validation & Accessibility –

Web Page Loading Time Analyzer –

Epic Games Releases Unreal Engine 3 for FREE

Leave a comment Standard

Talk about a diamond in the rough! Unreal Engine has been at the forefront of 3D games for years and the development kit is available to anyone now. Way to go Epic! You’ve just opened a brand new market to us independent game developers and given us a chance to step up like never before.

Get it today! Download it at their website