Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Cron and Crontab?

Tags:

unix

cron

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?

like image 463
NoobEditor Avatar asked Feb 14 '14 20:02

NoobEditor


People also ask

What is cron and crontab in Linux?

Updated: 11/16/2019 by Computer Hope. On Unix-like operating systems, the crontab command opens the cron table for editing. The cron table is the list of tasks scheduled to run at regular time intervals on the system. The daemon which reads the crontab and executes the commands at the right time is called cron.

What is the difference between crontab and at?

The Linux utilities cron and at are related commands. The cron utility allows you to schedule a repetitive task to take place at any regular interval desired, and the at command lets you specify a one-time action to take place at some desired time.

What crontab means?

crontab is a UNIX command that creates a table or list of commands, each of which is to be executed by the operating system at a specified time. crontab is used to create the crontab file (the list) and later used to change the previously created crontab file. Also see CRON script.

How many types of cron are there?

Crontab (cron table) is a text file that specifies the schedule of cron jobs. There are two types of crontab files. The system-wide crontab files and individual user crontab files. Users' crontab files are named according to the user's name, and their location varies by operating systems.


1 Answers

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.

like image 127
Ben Whaley Avatar answered Oct 24 '22 19:10

Ben Whaley