51
votes

I am not able to understand the answer for this question: "What's the difference between cron and crontab." Are they both schedulers with one executing the files once and the other executing the files on a regular interval OR does cron schedule a job and crontab stores them in a table or file for execution?

Wiki page for Cron mentions :

Cron is driven by a crontab (cron table) file, a configuration file that specifies shell commands to run periodically on a given schedule.

But wiki.dreamhost for crontab mentiones :

The crontab command, found in Unix and Unix-like operating systems, is used to schedule commands to be executed periodically. It reads a series of commands from standard input and collects them into a file known as a "crontab" which is later read and whose instructions are carried out.

Specifically, When I schedule a job to be repeated : (Quoting from wiki)

1 0 * * *  printf > /var/log/apache/error_log

or executing a job only once

at -f myScripts/call_show_fn.sh 1:55 2014-10-14

Am I doing a cron function in both the commands which is pushed in crontab OR is the first one a crontab and the second a cron function?

1

1 Answers

61
votes

cron is the general name for the service that runs scheduled actions. crond is the name of the daemon that runs in the background and reads crontab files. A crontab is a file containing jobs in the format

minute hour day-of-month month day-of-week  command

crontabs are normally stored by the system in /var/spool/<username>/crontab. These files are not meant to be edited directly. You can use the crontab command to invoke a text editor (what you have defined for the EDITOR env variable) to modify a crontab file.

There are various implementations of cron. Commonly there will be per-user crontab files (accessed with the command crontab -e) as well as system crontabs in /etc/cron.daily, /etc/cron.hourly, etc.

In your first example you are scheduling a job via a crontab. In your second example you're using the at command to queue a job for later execution.