Alright In this blog post. I will show you how to set up a Cron job in ubuntu. (Note the same steps can be used to setup a cron job on any other linux distro as well.)
Ok, Now time for some basics about what a Cron Job is.
Essentially a Cron Job helps to to perform a predefined task (or a set of tasks) at time intervals set by you (The User).
So What is the need for setting up a Cron Job you ask ???
Ok, Now time for some basics about what a Cron Job is.
Essentially a Cron Job helps to to perform a predefined task (or a set of tasks) at time intervals set by you (The User).
So What is the need for setting up a Cron Job you ask ???
- Well a vague example would be to set a script that automatically backs-up you home folder say at 12:00 AM every day.
- Another example would be to get your external IP and set it to your drop-box, so that you can access your computer or say view a hosted web site (Assuming you are broke as me and cannot afford a domain :P ;) )
- So on and so forth.
Now that we are done with what is a Cron job and with a possible idea of when to use one lets get right into it and set-up a cron job that basically does nothing but print to a file every minute.
(I know this is really stupid but it serves as a good example and hopefully help you build off of)
The Environment that I have is a Ubuntu 12.04 LTS, so if you have a similar set-up then just follow along and rest assured that things will work like magic. Even if you are on any other distro the steps would still be the same and wont be too hard to follow along ( I hope).
- STEP ONE:- CRON JOB INSTALL
- STEP TWO:- SETUP A CRON JOB
- The Process that I will be talking about is setting up a cron job using a Cron file.
- (Why this and not using corn-tab -e, as most other tutorials show,) Well that is exactly why, I wanted this to be a little different from the others and I feel this is a lot easier to understand and to expand upon as well)
- Ok down to the real deal. Open up a Console(ctrl+alt+t for ubuntu users).
- First stop create a crontab file any where you please. I would do so in the root of your home directory,( Note that this cron job will be available for this user only). Like So touch crontab.txt
- As far as I know almost all linux distros come with the cron utility pre installed (Nothing to do yay!!)