Knowledgebase

Shell and Automation: Everything That Matters, Briefly Print

  • programminglanguages, programming, errors, guide, howto, solution, zillionkinghost, hosting
  • 0

The summary.

SET EXIT-ON-ERROR AND QUOTE EVERY VARIABLE

Without those, a script continues after a failure and causes damage, and an unquoted variable splits on spaces.

The classic disaster is a deletion where the variable was empty, so the path became the root. Check variables are non-empty before using them in paths.

USE A SHELL SCRIPT LINTER

It catches the majority of common faults automatically.

POWERSHELL PASSES OBJECTS, NOT TEXT

Which removes output parsing entirely — the place traditional shell scripts are most fragile.

YOU HAVE OUTGROWN SHELL WHEN FUNCTIONS AND ARRAYS APPEAR

Move to a general-purpose language then, for error handling, testability and libraries.

SCHEDULED TASKS RUN WITH A MINIMAL ENVIRONMENT

Use absolute paths, always. Scripts working manually and failing when scheduled is nearly always this.

ALERT WHEN A SCHEDULED TASK DOES NOT RUN, NOT ONLY WHEN IT FAILS

A task silently ceasing is invisible for months.

ADD A DRY-RUN MODE, LOGGING, AND SAFETY TO RUN TWICE


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot