If you have a task at hand that you run at least once a week, where you have bunch of command and switches, where the computer just run some automated tasks one after another, for instance, shuts down an application, goes to a specific location in the system or remote system, deletes temporary files, grabs a copy of a specific file, overwrites it with the new one, makes a backup, restarts the application etc. Imagine how it would be to run this manually every week and to spice things up, not always we are up to the energy for the day and we may make typos, then we will have to start them over and over again.
How can you automate your system tasks?
To save you from this hassle you can grab all of these texts and save it a new file with the extension of .bat let’s say. So the file name would be something like, weeklyMaintenance.bat. Now the operating system will know that this is a shell script. Now the question is, how would run this script? Do we need any third party IDE, VScode studio, notepadd++ to run these? No, we already have our command prompt to run this file.
You simply run this weeklyMaintenance.bat from the command prompt. With this, you basically tell the command line to run a sequence of commands.
Examples of automation
For this very reason, many top-notch techs in the industry use scripting all the time to perform a vast amount of tasks all the time. For instance, Professor Mike Meyers is like the guru of IT industry, he has a small home office with lot of computers. His system admin has to perform one major task each morning checking for all the machines health, like – looking for any errors, if they are functioning well and so on. This may sound like that is not so much. But trust me, this is a lot of work and this has to be done on each and every computers. Now imagine if he has more computers on the network spread across the region? This would take the whole day to just perform this task.
Instead, the system admin comes in the morning, turn on his Mac, has a good mug of coffee and runs a number scripts and he watches all this tasks being performed on each computer while he sips a good morning coffee and wait for the report. Note one thing and let’s get it downright clear here. You run these scripts on a command prompt, but you create these scripts in text editor of your choice. In Windows, Notepad is a simple built-in text editor that comes in with Windows, we have vi and vim for Linux.
This weeklyMaintenance.bat we created earlier is called a batch file with the extension batch with it. Yet, by no means this is the limit of creating scripting for your system and certainly not limited to just .bat or batch file scripting. You have a plenty of tools at your disposal, be it built-in or third party that you can use, to make heavy weight scripting for intense task or to play around. Also, these tools are providing a way more to the surface and underground that normal built-in editor generally provide.