6.7 Wajig Automatic Daily Updates

20210401 Wajig can be run from crontab to automatically update your system daily. This is best practise in today’s environment where it is certain that the software we are running has bugs and flaws that can be quickly taken advantage of if not patched. The simplest approach is to add an entry to the system administrator (root) crontab. For the first time you may find that you are asked to configure an editor. If you don’t have a preference, go with nano.

$ sudo crontab -e

no crontab for root - using an empty one

Select an editor.  To change later, run 'select-editor'.
  1. /bin/nano        <---- easiest
  2. /usr/bin/vim.basic
  3. /usr/bin/vim.tiny
  4. /usr/bin/emacs
  5. /bin/ed

Choose 1-5 [1]: 

Decide on the frequency of the upgrades. This can be anything really, but a good choice is to upgrade at 3am every day. The following crontab entry does this:

# m h  dom mon dow   command
0 3 * * * (wajig update; wajig distupgrade --yes) > /home/kayon/cronlog_`date +\%Y\%m\%d`.log 2>&1

Notice the helpful comment lines in the crontab file as a guide to the format of an entry: m (minute); h (hour); dom (day of month); dow (day of week); and then followed by the command to run. A * for any of the date/time fields represents any.

The command here uses parentheses to group two commands and have them executed in a sub-shell. This then allows the output from both to be redirected to a file in a user’s home directory. The file has the current date as a suffix. Any errors written to stderr (file descriptor 2) are appended to stdout (file descriptor 1 the default for the first redirect >).



Your donation will support ongoing availability and give you access to the PDF version of the book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.