StuffIKnowAboutComputersAndTheWeb > Crontab

Crontab is the UNIX-y way to make things happen on a schedule on your server. It's not that hard to do, and there are a ton of good tutorials out there. However, here's a few tips for the UNIX newbie for surviving in Cron.

  • Don't follow the tutorials' suggestion to edit your Crontab file in Vi/Emacs/whatever they prefer; you can do it in the comfortable environment of the editor you're used to. Just:
    • Create a plain text file with each cron command on one line
    • Save it on your computer (say, as crontab.txt)
    • FTP it to your server
    • Log in via SSH
    • Type crontab crontab.txt and press enter. This will load the contents of your crontab.txt file (or whatever you called it) that you just uploaded into the contents of the system crontab file.
    • To confirm that everything worked fine, type crontab -l and press enter. This will show you the contents of the system crontab file.
  • If you don't want to have the output of successfully-executed commands e-mailed to you, add >/dev/null to the end of your command. I suggest you do this only after ensuring that your cron job is running successfully.
  • If you don't even want to have errors e-mailed to you, add 2>&1 after >/dev/null. I suggest you do this only after ensuring that your cron job is running successfully.

This page last modified on September 24, 2006, at 12:14 PM

This work is licensed under a Creative Commons License

Recent Changes | Page History | Edit Page