CRON will do your bidding


It’s common knowledge that everyone dreams about one day having their own evil robots to do their bidding… ok so maybe that just me

I’m not an electrical engineer, so my dreams of having a physical robots under my control most likely won’t come true, but I am a decent programmer and computer nerd, so the option of having invisible virtual robots is very realistic.

I would like to introduce you to CRON. Cron is a deamon program (I told you I liked evil robots!) that lives in most unix and linux powered machines (that includes you mac users!). To sum it up, cron runs tasks on a schedule for you. For example, backups of data are important, but time consuming, and are easy for a system admin or user to forget to do. Cron doesnt forget….being the evil robot that cron is, he will do whatever you tell him to do, including grunt work like creating back ups. If you want to get fancy you can mix in some php and a little mysql, and do all sorts of wild things like have him manage your twitter account, but I would never do that!

Here is a very helpful image that will give you an idea of how to schedule tasks for cron to handle.

cron commands

Click to make larger

As you can see, cron is very flexible and can be commanded to do anything, at any time. Cron will handle anything you throw at him, he can email you the results if you want.

Some of the things that I use cron for include:

  • backing up files
  • backing up databases
  • consuming rss feeds into wordpress
  • optimizing MySql database tables
  • emailing me error reports on my server
  • generate site maps and submit them to google
  • a few things here and there with twitter (shhhhh, its my secret!)

All in all, having automated tasks can really free you from a lot of admin duties, and make your life a lot easier, and can empower you to do a lot of interesting things with your server / personal computer.

Do a google search on cron and you will find all sorts of good resources that will teach you better then I can on how to use cron succesfully.

I will be making some posts in the future showing some of the scripts that I have cron run for me. Until then, read up on cron and start build you own evil robot army!