Tuesday May 28, 2024

now playing: Tomb Mold - Planetary Clairvoyance
Tomb Mold - The Enduring Spirit
Tomb Mold - Manor of Infinite Forms
Blood Incantation - Hidden History of the Human Race
Blood Incantation - Starspawn

crontabbing for regular occurrences

What is crontab? crontab is a feature of cron which helps you with cron jobs1. cron is a scheduling program, named for the Greek word "chronos" from which we get such words as chronicle and chronological2 for things which happen regularly, like backing up files, checking your email, etc. These are referred to as cron jobs and can be run as specific commands, scripts, or programs. This program is almost 50 years old! (It actually had its birthday this month (May)) One time future events can be scheduled with the at command. Accessing the crontab for the present user (and by default also creating a new one if one doesn't exist yet) is a very simple command to run: crontab -e. The basic syntax for each crontab entry is really, quite straightforward, and consists of five columns delineating when the job should occur and then the command, script, or program to run with whatever flags/options one chooses. The five columns laying out the timing are as follows, from left to right: seconds from 0-59, hours from 0-23, day of the month from 1-31, month from 1-12, day of the week from 0-6. Any of these can take a list or range of values (i.e. for month you might say 12-4 for something from December to April or 5,10,13 under days of the month for something to run on the fifth, tenth, and thirteenth day of a month, or a wildcard for all possible values. The only possibly difficult thing might be remembering that Sunday is listed as day zero of the week).

So, I just did some simple crontabbing for reminding myself to take my medication (scheduled to run at 10 am and another similar message at 1 pm) every day from Monday to Friday, to see if I've paid my rent on the 1st and 28th of each month (why the 28th? because I can't be bothered to learn a clunky way to find whatever the last day of any given month is with the different last numbers it can be, and to automatically tell my computer to shutdown at 11:30 pm and again at 2:30 am (second one being a failsafe in case for some reason I'm up at that time). Could I have used a different calendar program for these things? Yes, but the command line is more fun, and besides, these are regularly occurring things and I prefer calendar programs for discrete events like doctors' appointments.

Read more at the Wikipedia entry for cron.

  1. No, I'm not working in the cannabis industry, nor do I have any plans or plants to do so.
  2. Chronos is also sometimes used as the English name for the Klingon (or should I say tlhIngan name for the Klingon homeworld Qo'noS.


               O tessa o
          _\_   o
       \\/  o\ .
       //\___=
          ''



<< previous entry <<
<< back to list of blog entries <<