Crontabs

crontab, CSS sheet, gitignore file - all belong in the group of files that record actions to perform when pattern-matching onto a tree. For CSS sheets, apply style onto the DOM; for gitignore, not-tracking file onto the file tree, and for crontab, execute command onto the time tree.

The Crontab is edited by command, creating a temporary directory like /tmp/crontab.od9c72, where the suffix is a randomized alphanumerical ID. It stores a "crontab" buffer, opened with the preferred terminal editor e.g. nano.

  crontab -e
  

The Crontab host lines, each mapping a time pattern to a command. Cron then runs the command at the periodicity specified by the matching pattern.

  * * * * * ~/bin/cron-minute.sh >> \
   "/tmp/cron-$(date +\%Y-\%m-\%d)" 2>&1
  30 12 * * * ~/bin/cron-midday.sh > \
   "/tmp/cron-midday" 2>&1
  

This Crontab executes a script each minute, and another daily at 12:30 PM, appending stdout and stderr to log files. Syntax errors will prompt user for a retry. Ensure target scripts are chmod +x.

Running a script at second intervals.

Cron runs at maximum frequency of once per minute. If a script needs to run more often, it is not the proper tool, but a quick hack is to duplicate jobs, introducing shifted delays beforehand. It's a poor solution because there is still a one minute delay between changing the script, and seeing its effects. For example, this crontab runs a script each 20 seconds.

  * * * * * ~/bin/cron-update.sh
  * * * * * sleep 20; ~/bin/cron-update.sh
  * * * * * sleep 40; ~/bin/cron-update.sh
  

System-wide crontabs.

The system-wide crontab is a single file at /etc/crontab, directly editable unlike user crontabs relying on the command to be installed and edited.

Some fixed cron files also installed in directories like /etc/cron.*/, including

For example, /etc/cron.weekly/man-db, used to weekly update index man database caches. Some older distributions rely on this to clear out /tmp/.

Git Directed Acyclic Graphs

Git commits form a graph. The hash is a UID for the node. Git graphs are directed and acyclic, plus guaranteed to be finite. This makes them a good example of DAG that are not trees. When merged, a commit (vertex) gets two parents. Similar to finite trees, recursion is guaranteed to end.

A graph view can be generated with the --graph option.

    git log --graph --oneline --all
  

Pretty Format

This command generates a plain sequence of git commits.

    git log --pretty=format:"%h%x09%an%x09%ad%x09%s"
  

It can be marked up with the TIME element, with the following attribution: - datetime wraps the ISO timestamp - ID wraps the commit hash / prefix - the rest is included as text content of the TIME element.

Via this method, CSS can be used to "query" the sequence, highlight certain commits, etc. See the example below, which targets a specific commit hash and reduces the opacity of prevs.