Cron Jobs

Cron jobs are the Linux/UNIX world’s scheduler. Many people, myself included, have a hard time understanding crons. After all, setting one up is very simple, if you know what you are doing.

The Crontab
crontab” is the utility you use to setup a cron job. Type “crontab -e” from the command prompt to edit your list of crons. It’s just a textfile with a special format. Each non-blank line is a cron job. The format of each line is 6 space separated fields. Here is what each field defines:

  1. Minute
  2. Hour (Military Time)
  3. Day of the Month
  4. Month
  5. Day of the Week (0 is Sunday, 1 is Monday, etc.)
  6. Program to run w/any arguments (may include spaces)

The Date/Time fields may be a specific number, a “*” meaning anything, a “*/x” meaning every x hours/minutes/etc., or a comma separated list of any or all of the above.

So, if you wanted a certain program to run every 30 minutes, you could say it any of these ways:

*/30 * * * * /path/to/program arg1 arg2
0,30 * * * * /path/to/program arg1 arg2
12,42 * * * * /path/to/program arg1 arg2

Use Absolute Paths
If you are writing a script to run as a cron, you must make sure your script uses full paths or it will throw an error. Yes, the script will execute without error when run from the command line, but the cron will crap out.


0 2 1 * * /home/apache/

Runs the script the first of every month at 2AM.

0 17 * * * /home/oddjob/

Runs the script at 5PM every day.

0 17 * * 1,2,3,4,5 /home/oddjob/

Runs the script at 5PM Monday – Friday.

0 4 * * 1 /usr/sbin/mysql_dump > /backup/mysql/backup-`date "+%Y-%m-%d"`

Performs a weekly backup of the mysql database Mondays at 4AM.

0 0 1,15 * * /home/accounting/

Runs on the first and fifteenth of every month at 12 midnight.

Points to remember

  • Use full paths in scripts
  • The crontab is only for the current user

Vim quick start

Vim is a open source text editor.  I fell in love with it a few years ago.  It runs on Linux, Windows, Macs, and others.  The interface is pretty much the same across the board. It really is full-featured.  It highlights almost any file syntax from PHP to python to httpd.conf.

One major barriers to its popularity is its learning curve.  Vim was designed to be used entirely by a keyboard.  To start, download it and install it.  If you’re running linux, it should be preinstalled.  Once it is installed, run it by running vi. When you run it, you can only scroll.

Press the i key or the insert key to go to insert mode and you can type all day long. Press the escape key to exit insert mode.

You can do a quick search by pressing forward slash and typing your search. To repeat the last search press the foward slash then enter.

All the other basic commands start with a colon.  Here are a few to get you started:

  • :w — write the file
  • :sav filename — save the file to filename
  • :q — quit
  • :n — go to the next file
  • :N — go the the previous file
  • :wq — write the file and quit
  • :q! — quit now!
  • :wn — write the file andd go to the next file

There is a key difference between “:q” and “:q!”.  The first will not quit if the file has been changed or there are more files to edit.  The second will quit immediately.

There are  a ton more features than what is listed here.  When you are ready to continue learning vim, type :help for a help screen.  Type :q to exit the help.

Happy editing.

Corporate Linux

Large corporations are shoveling cash into Microsoft by buying their software which requires minimal setup for running a large network of corporate machines. Large organizations think it’s cost effective versus Linux, and they’re probably correct if someone in the corporation develops software using GPL software as a base for the project. How many large corporations do this? Very few.

Most corporations do not use Linux because they think the change over will cost them a lot of money. While this may be true for almost any large bank of computers, the cost in the long-run is much better with Linux than Windows. Cost is only 1 benefit of changing over to Linux.

Another benefit is security. Almost every program designed to run on Linux is created by the community, so bugs and security holes are found and fixed quicker than Microsoft can do it. The updates can be pushed using a free program found on the internet and installed on every machine, or individual ones.
The change over does require some user training, but it’s pretty simple to learn. At my work, we use a lot of free software that is available for Window and Linux; however, we run Windows on all our machines, except the web servers which run Linux.

Most people will use an app for business, another for email, and a basic web browser. If the business app was written for Windows, the change over cost can be astronomical, but if the app is web based, the change over cost is minimized. Email is email and the web is the web, no matter what program you use to access it.
Watch out though! Sarbanes-Oxley entangles Linux with a lot of red tape. This is mainly due to the fact that the CEO is personally responsible for all reporting of intellectual property information as well as all financial information.

If a corp is simply using it as an OS, the red tape is only a couple of levels thick. If anything is modified, the layers of red tape can amass pretty quickly. This is due to the wording of the GPL, the most common open source software license for Linux programs.

I asked the tech guy at my work if we could do a change over and he said it would be a bunch of red tape, mainly due to the rewriting of policy and building desktop OSs from scratch. I agree with the building the OS from scratch, which I have done before and is pretty simple once you’ve done it a few times. Policies need to be rewritten anytime an OS change over takes place, so go ahead and make the policies!

Anyways, for any corporation just starting out, go with Linux. It’s a lot cheaper than Windows, $0 vs. $300. It can be a pain to set up if you are not familiar with it, but you’ll save $300 per machine. That’s enough to pay someone for 30 hours of work at $9.29, $0.71 is taken off the top for business paid FICA taxes. Plus if you buy all the same machine, once it’s setup on one, you can simple copy hard drives to get it on all the other machines.

Death of Windows XP

Windows XP will be pulled from the shelves in less than 3 months time. The official finale will be observed June 30, 2008. Many people are up in arms over this. There is even a petition to keep XP on the shelves. As the date nears, I am advising people who will be in the market for a new computer between now and 2010 to try Linux.

Try it, that’s all I ask. Linux has advanced dramatically from it’s conception in 1991. There are several distributions, or flavors, that offer a LiveCD or LiveDVD. A LiveCD/LiveDVD is simply a copy of Linux that runs directly from a burned CD/DVD. It installs nothing to your computer, so you aren’t forced to do anything to your computer except drop the disc in and reboot.

Many of these LiveCDs allow you to install Linux after you have tried it. For a newbie, or noob(pronounced the same way), Ubuntu is your best bet. Anyone with a blank CD-R, a CD burner, and a high speed internet connection (or a friend with high speed) can do it.

Linux is different from Windows; however the KDE desktop environment is very similar to Windows and comes with a Redmond* Theme that looks almost exactly like Windows XP. The programs are called different names, but you can enjoy a lot of the same programs, like Firefox.

I know, some of you might be saying, “What about my games?” They’ve got most of them covered too. There’s a Windows Emulator** called Wine. There’s also a program call PlayOnLinux which sets everything up for many many Windows programs, including my favorite game, WoW.

So, give it a try! You might be sorely disappointed, but I doubt you’ll be that disappointed.

* Microsoft is based in Redmond, WA. Hence the name.

** An emulator is a program, or set of programs, that allows you to run a different system of software, such as Playstation or Windows.