Cron is a daemon on Linux and UNIX platforms, which makes automating tasks a simple matter.
"Daemons" are programs that usually sit and wait dormentantly on a system until told to do something. A web server is also an example of a "daemon".
Why cron is great and when to use it
Cron is great because it allows you to easily automate as many things as you like on a *nix computer. It can either run system commands, or launch executable binaries or scripts. For example, let's say you want to make a weekly backup of your site; this is where cron comes in - it does it all for you so you never have to think about it and do it yourself. Cron is really flexible and can run at specific times or simply intervals as low as every minute.
Therefor, you use cron whenever you want to automate something (no matter how simple or complex it may be).
How can I tell if I have cron installed?
Most modern distributions of Linux will come with a cron daemon installed, and typically ready to use, from a default installation. To see if you have cron, use the following command in a shell:
BASH CODE
ps auwx | grep cron
If you see a path output, other than your "grepped" command, then cron is up and running. Here is an example result from running the above command, which shows cron is running:
RESULT
root 3147 0.0 0.0 2196 896 ? Ss Jun04 0:08 /usr/sbin/cron
root 16685 0.0 0.0 3328 668 pts/0 S+ 15:42 0:00 grep cron
How does cron work?
Cron works by using a list of "cronjobs". These are simple one line instructions to a command, program or script to be run at a specified time or interval.
How can I add cronjobs?
To add, delete or modify your cronjobs, write the following code in a shell:
BASH CODE
crontab -e
This will open up your user's (cron is a multi-user daemon, so all system users have their own cronjobs) crontab, using your default command line text editor. Let's assume that it is nano for this guide, since this is what I am using, and this is what seems to be set as the default editor on most Linux distributions.
You will probably see this at the top line:
# m h dom mon dow command
Any lines prepended with a hash sign (#) will be interpreted as comments and ignored by the cron daemon. This is just a friendly reminder the cron daemon throws in to help you remember the syntax; and that syntax is:
minutes hours day-of-month month day-of-week command
So let's suppose you want to add a cronjob that is to be run every day at 10 in the morning. First you create a new line (as each line in the crontab file is a different cronjob) and write something like this on the line:
0 10 * * * /path/to/script.sh
The wild card character (*) is used when you want cron to match anything for that particular field. Similarly, the wild card character can also be used to run a command every 5 hours, or even every 5 minutes. Here is how you would create a cronjob that gets executed every 5 minutes:
*/5 * * * * /path/to/script.sh
... And here is how you would create a cronjob that gets executed every 5 hours:
* */5 * * * /path/to/script.sh
Suppose you want to schedule a certain task or command for a specific date and time. In this case, let's assume it is at 4:20am on April 20th; here is how you would add that job:
20 4 20 4 * /path/to/script.sh
It's also possible to schedule a cronjob for a certain day of the week. Let's assume you want a command to be run every Wednesday at 7pm. Here we would use the last parameter before the command (for day or week). The value should be from 0-6 (Sunday = 0, Monday = 1, Tuesday = 2, etc.). Here is how the cronjob entry should look:
0 19 * * 4 /path/to/script.sh
Additionally, you can schedule cronjobs by using , , , , and instead of using the five time related fields. Suppose there is something you want run every time your computer reboots; to do this, use:
/path/to/script.sh
If you want something run once a month, you can use this:
/path/to/script.sh
And running something every day is done like so:
/path/to/script.sh
Scheduling cron jobs within Theia
Theia comes with a built-in cron job management tool, which will allow you to add, modify and delete Theia related cron scripts automatically through a visual interface. This means, you do not need to use a shell and write in commands to schedule tasks within Theia. To use this tool, look in "tools" for a tool named, "cron configuration & management" (admin tool 010).






