Chapter 10. Scripting and Automation
Sysadmins automate what they can. But you can’t automate everything. Automation is a good thing but has its limitations. In this chapter, I discuss both the pros and cons of automation. Some tasks are difficult to automate because they involve too many variables. And automation does come with some security risks because automating tasks that require elevated privileges creates security holes that can lead to system compromise. Other obstacles to automation include timing and time drift, system failure, script error conditions, and human interactions.
Creating scripts and automating tasks is challenging and fun. Watching a series of scripts and schedules work as planned to mimic human keystrokes, decisions, and activities is rewarding. Every sysadmin must know how to create basic shell scripts and should automate every possible nonprivileged, repetitive task. This chapter covers the concepts of scripting and automation but not the low-level mechanics of scripting (loops, file I/O, etc.), which are well-documented on the web.
Answering the Question: Why Automate?
I’ve had a few sysadmins ask me why they should automate anything. The answer is simple: so you can focus on higher-level tasks while your computer systems handle the mundane, daily jobs that you must perform but that a CPU and some memory can address without making mistakes. Do you want your day filled with the drudgery of manually creating backups, copying backups to an archive location, ...
Get Practical Linux System Administration now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.