Backdrop CMS: How to create a command-line (cli) script or routine

I often need to run routines (that might take a long time) from the command line. For example, a nightly import of thousands of records. I did this all the time in Drupal 7, but initially couldn t figure out how I should set it up in Backdrop CMS. (For those that don t know, Backdrop is a fork of Drupal 7, but currently being maintained and with new features added on.) Here s how you need to set…