Oct
23
2006

Linux Basics – How to use Cron to automate just about anything including backups

Cron is one of those little programs that can change the world. It’s a scheduling progam, meaning that you can give it instructions such as ‘at 10:45am on every Monday run this program’ and it will faithfully wait until the appointed time to do what you asked it.

Why is this useful? Cron can be used to automate tasks such as backups, the running of hourly, daily weekly monthly or yearly reports, and just about anything else you can think of. This will be a basic guide to using cron. Specifically, to run the backups we discussed earlier.

In it’s basic form, Cron is told to do things by text files called crontabs, which are located in /var/spool/cron/crontabs. When Cron is launched (and every minute after that) it checks this directory for crontabs, and loads these into memory for execution at the appropriate time. If any single crontab shows a modified timestamp been modified, it checks them all to be sure nothing else has changed.

Editing a crontab is fairly easy. If you’re used to Nano, you can simply type:

crontab -e

If you’re more comfortable with a GUI editor like Gedit, you can type:
EDITOR=gedit crontab -e

Here’s where an important distinction needs to be made. Each user can have their own Crontab, including root. If you want or need to run something with root privilages, it’s a good idea to do the following:

[More in this Article...]

Linux Basics – How to use Cron to automate just about anything including backups

Originally from ArsGeek by arsgeek

Leave a Comment

Name (required)

Email (required)

Website

Comments

2006 (c) Tech Tips, Using the ReviewSaurus Theme : Powered by WordPress