{"id":1354,"date":"2021-12-07T19:13:25","date_gmt":"2021-12-07T13:43:25","guid":{"rendered":"https:\/\/smarttech101.com\/?p=1354"},"modified":"2023-08-17T15:11:35","modified_gmt":"2023-08-17T09:41:35","slug":"cron-the-job-scheduler-in-linux-unix","status":"publish","type":"post","link":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/","title":{"rendered":"Cron: the Job Scheduler in Linux\/Unix"},"content":{"rendered":"\n<p><strong>Cron<\/strong> is a job scheduler utility in Linux\/Unix. It is used to execute commands (called <strong>cronjobs)<\/strong> at a given schedule without any human intervention. I can use it, for example, to backup and update my computer every Sunday or reboot my servers at the start of every month.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"table-of-contents\">Table of Contents<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#1-installation-and-early-preparation\">1. Installation and Early Preparation<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#1-1-installation-of-cron\">1.1. Installation of Cron<\/a><\/li>\n\n\n\n<li><a href=\"#1-2-activation-of-cron\">1.2. Activation of Cron<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#2-creation-of-cronjobs\">2. Creation of Cronjobs<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#2-1-cronjob-syntax\">2.1. Cronjob Syntax<\/a><\/li>\n\n\n\n<li><a href=\"#2-2-cronjob-examples\">2.2. Cronjob Examples<\/a><\/li>\n\n\n\n<li><a href=\"#2-3-advanced-crontab-examples\">2.3. Advanced Crontab Examples<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#3-listing-cronjobs\">3. Listing Cronjobs<\/a><\/li>\n\n\n\n<li><a href=\"#4-removing-cronjobs\">4. Removing Cronjobs<\/a><\/li>\n\n\n\n<li><a href=\"#5-manupulating-cronjobs-for-other-users\">5. Manupulating Cronjobs for Other Users<\/a><\/li>\n\n\n\n<li><a href=\"#6-a-little-warning-shell-and-path\">6. A Little Warning: $SHELL and $PATH<\/a><\/li>\n\n\n\n<li><a href=\"#7-anacron-icing-on-the-cake\">7. Anacron &#8211; Icing on the Cake<\/a><\/li>\n\n\n\n<li><a href=\"#8-wrapping-up\">8. Wrapping Up<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1-installation-and-early-preparation\">1. Installation and Early Preparation<\/h2>\n\n\n\n<p>Many distributions install it by default. But for barebone distributions like Archlinux, you might need to install it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-1-installation-of-cron\">1.1. Installation of Cron<\/h3>\n\n\n\n<p><strong>Archlinux<\/strong> based distributions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo pacman -S cronie<\/code><\/pre>\n\n\n\n<p><strong>Fedora<\/strong> based distributions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo dnf install cronie<\/code><\/pre>\n\n\n\n<p><strong>Debian<\/strong> based distributions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo apt install cron <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-2-activation-of-cron\">1.2. Activation of Cron<\/h3>\n\n\n\n<p>Now, activate the cron daemon using systemd.<\/p>\n\n\n\n<p><strong>Archlinux<\/strong> and <strong>Fedora <\/strong>based distributions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo systemctl enable cronie.service<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo systemctl start cronie.service<\/code><\/pre>\n\n\n\n<p><strong>Debian<\/strong> based distributions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo systemctl enable cron.service<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo systemctl start cron.service<\/code><\/pre>\n\n\n\n<p>Now that we have set up cron, we will be learning about creating cronjobs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-creation-of-cronjobs\">2. Creation of Cronjobs<\/h2>\n\n\n\n<p>Cronjobs are created using the following crontab command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ crontab -e<\/code><\/pre>\n\n\n\n<p>The above command opens a text file using the editor specified by the <strong>VISUAL<\/strong> or <strong>EDITOR<\/strong> environment variables. If you have not specified the variable, it uses the <strong>Vi<\/strong> editor. And if your system does not have <strong>Vi<\/strong> editor installed, it might throw another error saying it. In that case, you will need to supply <strong>EDITOR<\/strong> as well:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ EDITOR=nano crontab -e<\/code><\/pre>\n\n\n\n<p>Here, in the text file, we write our cronjobs. Your output might look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Chronological table of program loadings                                       \n# User: johndoe\n# source: https:\/\/wiki.archlinux.org\/title\/cron\n\n# mm  hh  DD  MM  W \/path\/progam\n  21  01  *   *   * \/usr\/bin\/systemctl hibernate\n  30  06  *   *   1 \/usr\/bin\/ubdatedb<\/code><\/pre>\n\n\n\n<p>In the above example, each line corresponds to a single cronjob. And empty lines and comment lines (lines starting with a <strong><code>#<\/code><\/strong>) are ignored. These cronjobs are written in special syntax which is described below.<\/p>\n\n\n\n<p><strong>Note<\/strong>: The <strong><code>crontab -e<\/code><\/strong> command is used to create cronjobs for the user who executed it. To create cronjobs for the root user, use the <strong>sudo<\/strong>. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo crontab -e<\/code><\/pre>\n\n\n\n<p>As stated above, you might need to supply the <strong>EDITOR<\/strong> variable also. These <strong>root<\/strong> user&#8217;s cronjobs will have administration-level permissions. <mark>Hence, they will be able to execute commands like <strong>system update<\/strong>.<\/mark><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-1-cronjob-syntax\">2.1. Cronjob Syntax<\/h3>\n\n\n\n<p>Each cronjob has 6 <strong>fields<\/strong> separated by space. The first five fields are time and date fields:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>Fields<\/th><th>Allowed Values<\/th><\/tr><\/thead><tbody><tr><td>Minute<\/td><td>0-59<\/td><\/tr><tr><td>Hour<\/td><td>0-23<\/td><\/tr><tr><td>Day of Month<\/td><td>1-31<\/td><\/tr><tr><td>Month<\/td><td>1-12 (or JAN-DEC)<\/td><\/tr><tr><td>Week<\/td><td>1-7 (or MON-SUN; 0 can be used for SUN as well)<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Source: <strong>man 5 crontab<\/strong><\/figcaption><\/figure>\n\n\n\n<p>The sixth field is the command to be run. By default, this command is run by <strong>\/bin\/sh<\/strong> shell.<\/p>\n\n\n\n<p>The above description was all about basic cronjob expression. Now, we learn more about it through examples. There are some advanced formats as well which will be clear after we go through these examples.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-2-cronjob-examples\">2.2. Cronjob Examples<\/h3>\n\n\n\n<p>The simplest Example will be to execute the command <strong>once<\/strong> <strong>every minute<\/strong>. In the example given below, a <strong>star<\/strong> means all possible values (just like a star in <strong>bash<\/strong>).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>* * * * * echo $SHELL &gt; \/tmp\/shell.txt<\/code><\/pre>\n\n\n\n<p>Currently, I use the following cronjobs to <a href=\"https:\/\/smarttech101.com\/backup-and-restore-your-computer-using-rsync\/\" target=\"_blank\" rel=\"noreferrer noopener\">back up my PC using rsync<\/a> <strong>once<\/strong> <strong>every week <\/strong>(Monday<strong> <\/strong>at 6 AM).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#min hr day month w cmd\n0  6  *   *   MON \/home\/ajay\/.my_scripts\/rsync.sh -b<\/code><\/pre>\n\n\n\n<p>Similarly, I execute the <strong>updatedb<\/strong> command <strong>once<\/strong> <strong>every hour<\/strong>. It helps me in using <strong>locate <\/strong>command in my <strong>launcher.sh<\/strong> script to launch any files.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#min hr day month w cmd\n0  *  *   *   * \/usr\/bin\/ubdatedb<\/code><\/pre>\n\n\n\n<p>At the same time, the above cronjob example is the same as the following with <code><strong>@hourly<\/strong><\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#min hr day month w cmd\n@hourly \/usr\/bin\/ubdatedb<\/code><\/pre>\n\n\n\n<p>Just like above, we also have<strong> <\/strong><code>@yearly, @annually, @monthly, @weekly, @daily, and @reboot<\/code>. They mean:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   @reboot    :    Run once after reboot.\n   @yearly    :    Run once a year, ie.  \"0 0 1 1 *\".\n   @annually  :    Run once a year, ie.  \"0 0 1 1 *\".\n   @monthly   :    Run once a month, ie. \"0 0 1 * *\".\n   @weekly    :    Run once a week, ie.  \"0 0 * * 0\".\n   @daily     :    Run once a day, ie.   \"0 0 * * *\".<\/code><\/pre>\n\n\n\n<p>Moreover, I <strong>reboot<\/strong> a few of my servers in the night <strong>once every month <\/strong>(At 12:00 AM, on day 1 of the month) using<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#min hr day month w cmd\n0 0 1 * * \/usr\/bin\/systemctl reboot<\/code><\/pre>\n\n\n\n<p>Further, we can use <strong>\/n to create a periodic interval of n<\/strong>. For example, to execute a cronjob <strong>once<\/strong> <strong>every 2 hour<\/strong>s we will be using<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#min hr day month w cmd\n0 *\/2 * * * \/bin\/cmd<\/code><\/pre>\n\n\n\n<p>Another great example will be to execute a cronjob<strong> at the end of every month<\/strong> (at 12 AM). In the example given below a <strong>dash<\/strong> specifies range. So 28-31 means anything between 28 and 31. :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#min hr day month week\n00 00 28-31 * * test $(date -d tomorrow +%d) -eq 1 &amp;&amp; \/bin\/cmd<\/code><\/pre>\n\n\n\n<p>At the same time, We can also<strong> merge these syntaxes<\/strong> and create a complex cronjob schedule. For example, to create a cronjob <strong>every 1.5 hours<\/strong>:<\/p>\n\n\n\n<pre id=\"block-13206b14-c340-40cf-8710-931dc79b8095\" class=\"wp-block-code\"><code>#min hr day month week<br>0 0-23\/3 * * * \/bin\/cmd<br>30 1-23\/3 * * * \/bin\/cmd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-3-advanced-crontab-examples\">2.3. Advanced Crontab Examples:<\/h3>\n\n\n\n<p><strong>Example 1.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#min hr day month w cmd\n10 11 12-17 * WED \/bin\/cmd<\/code><\/pre>\n\n\n\n<p><strong>Meaning: <\/strong>At 11:10 AM, between days 12 and 17 of the month, and on Wednesday.<\/p>\n\n\n\n<p><strong>Example 2.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#min hr day month w cmd\n34-56\/2 * * * * \/bin\/cmd<\/code><\/pre>\n\n\n\n<p><strong>Meaning:  <\/strong>Here, <code>\/2<\/code> creates an interval of 2.<strong> <\/strong>So, this syntax means cronjob at every 2nd minute from 34 through 56 i.e. at minutes 34, 36, 38,&#8230;,56.<\/p>\n\n\n\n<p><strong>Example 3.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#min hr day month week\n10,20 1,3 * * *<\/code><\/pre>\n\n\n\n<p><strong>Meaning: <\/strong>Here, <strong>commas are used to create a list of numbers<\/strong>. So, the above syntax means &#8220;At minutes 10 and 20 past hour 1 and 3&#8221;. We can use <strong>a comma with a dash<\/strong> to create other ranges as well such as &#8220;0-4,8-12&#8221;.<\/p>\n\n\n\n<p><strong>Extra Information: <\/strong>You can also check on<a href=\"https:\/\/crontab.guru\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\"> Crontab.guru<\/a> &#8211; The Online Cron Schedule Expression Editor &#8211; to create more complex cron schedules. You can also use it to test your syntax before putting them in <strong><code>crontab -e<\/code>.<\/strong><\/p>\n\n\n\n<p>After adding these cronjobs, you can edit them in the future using the same <strong><code>crontab -e<\/code><\/strong> command. The previous text file will be opened. You just need to change the texts in it. You can add new lines for new cronjobs as well.<\/p>\n\n\n\n<p>Now that we have created some cronjobs, we will be learning how to do some manipulation like removing\/listing them, or allowing\/denying it for certain users.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-listing-cronjobs\">3. Listing Cronjobs<\/h2>\n\n\n\n<p>Command<strong> <code>crontab -l<\/code> <\/strong>lists the current user&#8217;s all existing cronjobs.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ crontab -l<\/code><\/pre>\n\n\n\n<p><strong>Sample<\/strong> <strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># comment\n* * * * * echo hello &gt; \/tmp\/test<\/code><\/pre>\n\n\n\n<p>Similarly, use <code>sudo<\/code> to list the <strong>root<\/strong> user&#8217;s existing cronjobs<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo crontab -l<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4-removing-cronjobs\">4. Removing Cronjobs<\/h2>\n\n\n\n<p>Command<strong> <code>crontab -r<\/code> <\/strong>is used to remove cronjobs<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ crontab -r<\/code><\/pre>\n\n\n\n<p>For the root user,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo crontab -r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5-manupulating-cronjobs-for-other-users\">5. Manupulating Cronjobs for Other Users<\/h2>\n\n\n\n<p>This requires administration-level permission.  All of the above-mentioned commands can be executed as other users using the <strong><code>-u<\/code> flag.<\/strong> For example, if a user named &#8216;admin&#8217; with administration level permissions wants to list all the cronjobs for another user named &#8216;another_user&#8217;, he can use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~# crontab -u another_user -l<\/code><\/pre>\n\n\n\n<p>Similarly, he can use <strong><code>crontab -u another_user -e<\/code> <\/strong>and <strong><code>crontab -u another_user -r<\/code><\/strong> for editing and removing cronjobs respectively.<\/p>\n\n\n\n<p>The admin user can also ban certain users from using crontab by putting their username in file <strong><code>\/etc\/cron.deny<\/code>.<\/strong> Similarly, he can put certain users in file <strong><code>\/etc\/cron.allow<\/code><\/strong> to allow only these users to use crontab.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6-a-little-warning-shell-and-path\">6. A Little Warning: $SHELL and $PATH<\/h2>\n\n\n\n<p>Sometimes, you might see <strong>PATH<\/strong> and <strong>SHELL<\/strong> environment variables are defined in the <strong><code>crontab -e<\/code><\/strong> as well:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PATH=\/home\/ajay\/.my_scripts:\/bin:\/usr\/bin:\/usr\/local\/bin\nSHELL=\/bin\/bash\n* * * * * echo hello &gt; \/tmp\/test.txt<\/code><\/pre>\n\n\n\n<p>The rationale behind the declaration is that crontab uses <strong>\/bin\/sh<\/strong> shell instead of the default shell of the user who created it. You can verify this using the following cronjob:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#min hr day month week\n* * * * * echo $SHELL &gt; \/tmp\/path.txt<\/code><\/pre>\n\n\n\n<p>This might lead to unexpected behavior &#8211; you, for example, might be using bash&#8217;s specific commands not available in <strong>\/bin\/sh<\/strong> (symlinked to <strong>\/bin\/dash<\/strong> in Ubuntu) and end up with errors.<\/p>\n\n\n\n<p>To know more about <a href=\"https:\/\/smarttech101.com\/hard-links-and-soft-links-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">symlinks, read my article on it.<\/a><\/p>\n\n\n\n<p>Similarly, it ignores the PATH variable of the user. Because of this reason, in all of my above examples, I am using the full path to command (\/bin\/cmd instead of just cmd).<\/p>\n\n\n\n<p>Likewise, to send <a href=\"https:\/\/smarttech101.com\/how-to-send-notifications-in-linux-using-dunstify-notify-send\/#Sending_Notifications_from_CronAnacron\">notification over notification-daemon such as <strong><code>notify-send<\/code>,<\/strong> we need to set <strong><code>DISPLAY<\/code><\/strong> and<strong> <code>DBUS_SESSION_BUS_ADDRESS<\/code><\/strong> environment variables as well. Learn how to do it over here.<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"7-anacron-icing-on-the-cake\">7. Anacron &#8211; Icing on the Cake<\/h2>\n\n\n\n<p>Unlike cron, anacron does not assume that your system is running continuously. And that is useful in the following cases:<\/p>\n\n\n\n<p>1. Your laptop\/desktop computer shuts down\/hibernates\/sleeps while a cronjob&#8217;s execution was underway. <\/p>\n\n\n\n<p>2. The computer is off while a cronjob was supposed to get executed.<\/p>\n\n\n\n<p>Next time, the computer starts the cronjob is executed.<\/p>\n\n\n\n<p>For more, see <a href=\"https:\/\/smarttech101.com\/how-to-use-anacron-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">How To Use Anacron In Linux<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"8-wrapping-up\">8. Wrapping Up<\/h2>\n\n\n\n<p>Cron (or Cronie) is a powerful tool to schedule your job. It is used widely in industries. Over time many new variations have popped up such as <code><strong>fcron, dcron<\/strong>,<strong> cronwhip, vixie-cron, scron<\/strong><\/code> for people with special needs. Alternatively, you can also use <strong>systemd-timer<\/strong> for setting up a minimal system &#8211; a default setting in Archlinux. <\/p>\n\n\n\n<p>Before I go I like to thank you to stay up to this point. If you still have any queries, you can read them in <a href=\"https:\/\/wiki.archlinux.org\/title\/cron#Crontab_format\" target=\"_blank\" rel=\"noreferrer noopener\">Archwiki<\/a>, <strong><code>man 8 cron<\/code>, <code>man 1 crontab<\/code>, <code>man 5 crontab<\/code>, <code>man 5 anacrontab<\/code>, <code>man 8 anacron<\/code><\/strong> or you can also put them in the comment section below. And also I have tried my best to make sure that there is not any mistake in the article. But, if there are still some mistakes, please notify me using the comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cron is a job scheduler utility in Linux\/Unix. As the name implies, it is used to execute commands (called cronjobs) periodically. I can use it, for example, to backup, and update my computer once a week or reboot my servers once a month.<\/p>\n","protected":false},"author":2,"featured_media":1375,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[48],"tags":[],"class_list":["post-1354","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-desktop-tools"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Cron: the Job Scheduler in Linux\/Unix | SmartTech101<\/title>\n<meta name=\"description\" content=\"Cron - a job scheduler utility - is used to execute jobs (called cron-jobs) like backup, reboot, and system update periodically.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Cron: the Job Scheduler in Linux\/Unix | SmartTech101\" \/>\n<meta property=\"og:description\" content=\"Cron - a job scheduler utility - is used to execute jobs (called cron-jobs) like backup, reboot, and system update periodically.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/\" \/>\n<meta property=\"og:site_name\" content=\"SmartTech101\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-07T13:43:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-17T09:41:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ajay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ajay_yadav\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/\"},\"author\":{\"name\":\"Ajay\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\"},\"headline\":\"Cron: the Job Scheduler in Linux\/Unix\",\"datePublished\":\"2021-12-07T13:43:25+00:00\",\"dateModified\":\"2023-08-17T09:41:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/\"},\"wordCount\":1302,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png?fit=1280%2C720&ssl=1\",\"articleSection\":[\"Linux Desktop Tools\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/\",\"url\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/\",\"name\":\"Cron: the Job Scheduler in Linux\/Unix | SmartTech101\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png?fit=1280%2C720&ssl=1\",\"datePublished\":\"2021-12-07T13:43:25+00:00\",\"dateModified\":\"2023-08-17T09:41:35+00:00\",\"description\":\"Cron - a job scheduler utility - is used to execute jobs (called cron-jobs) like backup, reboot, and system update periodically.\",\"breadcrumb\":{\"@id\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png?fit=1280%2C720&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png?fit=1280%2C720&ssl=1\",\"width\":1280,\"height\":720,\"caption\":\"Cron: The Job Scheduler in Linux\/Unix\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/smarttech101.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cron: the Job Scheduler in Linux\/Unix\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/smarttech101.com\/#website\",\"url\":\"https:\/\/smarttech101.com\/\",\"name\":\"SmartTech101\",\"description\":\"Do Everything in Linux\",\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/smarttech101.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\",\"name\":\"Ajay Yadav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"width\":180,\"height\":60,\"caption\":\"Ajay Yadav\"},\"logo\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\",\"name\":\"Ajay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"caption\":\"Ajay\"},\"sameAs\":[\"https:\/\/x.com\/ajay_yadav\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Cron: the Job Scheduler in Linux\/Unix | SmartTech101","description":"Cron - a job scheduler utility - is used to execute jobs (called cron-jobs) like backup, reboot, and system update periodically.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/","og_locale":"en_US","og_type":"article","og_title":"Cron: the Job Scheduler in Linux\/Unix | SmartTech101","og_description":"Cron - a job scheduler utility - is used to execute jobs (called cron-jobs) like backup, reboot, and system update periodically.","og_url":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/","og_site_name":"SmartTech101","article_published_time":"2021-12-07T13:43:25+00:00","article_modified_time":"2023-08-17T09:41:35+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png","type":"image\/png"}],"author":"Ajay","twitter_card":"summary_large_image","twitter_creator":"@ajay_yadav","twitter_misc":{"Written by":"Ajay","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#article","isPartOf":{"@id":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/"},"author":{"name":"Ajay","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334"},"headline":"Cron: the Job Scheduler in Linux\/Unix","datePublished":"2021-12-07T13:43:25+00:00","dateModified":"2023-08-17T09:41:35+00:00","mainEntityOfPage":{"@id":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/"},"wordCount":1302,"commentCount":1,"publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"image":{"@id":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png?fit=1280%2C720&ssl=1","articleSection":["Linux Desktop Tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/","url":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/","name":"Cron: the Job Scheduler in Linux\/Unix | SmartTech101","isPartOf":{"@id":"https:\/\/smarttech101.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#primaryimage"},"image":{"@id":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png?fit=1280%2C720&ssl=1","datePublished":"2021-12-07T13:43:25+00:00","dateModified":"2023-08-17T09:41:35+00:00","description":"Cron - a job scheduler utility - is used to execute jobs (called cron-jobs) like backup, reboot, and system update periodically.","breadcrumb":{"@id":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#primaryimage","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png?fit=1280%2C720&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png?fit=1280%2C720&ssl=1","width":1280,"height":720,"caption":"Cron: The Job Scheduler in Linux\/Unix"},{"@type":"BreadcrumbList","@id":"https:\/\/smarttech101.com\/cron-the-job-scheduler-in-linux-unix\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smarttech101.com\/"},{"@type":"ListItem","position":2,"name":"Cron: the Job Scheduler in Linux\/Unix"}]},{"@type":"WebSite","@id":"https:\/\/smarttech101.com\/#website","url":"https:\/\/smarttech101.com\/","name":"SmartTech101","description":"Do Everything in Linux","publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smarttech101.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633","name":"Ajay Yadav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","width":180,"height":60,"caption":"Ajay Yadav"},"logo":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334","name":"Ajay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","caption":"Ajay"},"sameAs":["https:\/\/x.com\/ajay_yadav"]}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Cron_Cronjob.png?fit=1280%2C720&ssl=1","_links":{"self":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1354"}],"collection":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/comments?post=1354"}],"version-history":[{"count":5,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1354\/revisions"}],"predecessor-version":[{"id":3035,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1354\/revisions\/3035"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media\/1375"}],"wp:attachment":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media?parent=1354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/categories?post=1354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/tags?post=1354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}