Say you have issued a command in your servers. Typically the command might either backup something or perform a critical hot fix.
Surely you know the start time of the process. But when it will end? How can you find the execution time, when the process has already been started?
People might manually change critical config files in servers occasionally. For example, /etc/hosts, /etc/hostname, etc.
As an experienced operator, you will remember to backup, before making any changes. Right? What would you do? cp /etc/hosts /etc/hosts.bak.
But is that good enough?
As DevOps or IT professionals, people may ask us why they can’t ssh to servers. It happens from time to time. Isn’t right? Not much fun. Just routine work.
Want to ease the pain and burden? Let’s examine common ssh failures together. Next time forward this link to your colleagues, if useful. People may be able to identify the root cause all by themselves, or be efficient in collecting all necessary information, before turning to us.
For DevOps, installation is one of our major tasks. People may wonder package installation is pretty straight-forward and easy now. Just run commands like apt-get, yum, brew, etc. Or simply leave it to containers.
Is it really that easy? Here is a list of headache and hidden costs. Discuss with us, DevOps gurus!
Apparently process checking is critical. Yes, we already have tons of linux tools and tips available. Getting familiar with your weapons is actually the first step, and the easiest part.
More importantly, what questions you ask, what for, when approaching your critical process. Fortunately even with plain common sense, we can dig out lots of valuable information.
In bash scripting, it’s a good practice to exit for any unexpected/unhandled errors. Usually I enforce this by ‘bash -e my_script.sh’. Today just got a surprise with ‘bash -e‘.
Check out below simple test. You might get bitten by this as well.
Ever need to check the output of shell functions/scripts? If no fatal/error messages found, resume normal procedure. Otherwise, go to error handling.
Usually people solve this, by redirecting stdout/stderr to grep command. But What About Time-consuming Functions/Scripts? Say several minutes. During this period, end users are blinded with nothing printed. It could be confusing and scaring to them.
Shell scripting is a must-have skill for DevOps. I used to be very very confident at Shell. But when I first tried ShellCheck , I realized that I’m just too proud and arrogant.
ShellCheck is a powerful code analysis tool for shell scripts. Like Pylint for Python or Rubocop for Ruby. Give it a try! You’ll get surprised.
Commands for Linux Package Management. e.g. apt-get, HomeBrew, Port