I think that it depends on your environment.
In my case, I have a lot of VMs. The majority of the VMs are either web servers or app servers. Given that we know exactly what's running inside (JVM with limited heap size, httpd, monitoring tools, ...), we decided to disable swap space and correctly size our RAM.
And I think that in a virtual environment, you already have the overhead of the hypervisor. And as a result swap in such an environment does not speed up things much. So, if you can, it is better to rely on RAM.
On a physical server, swap space may have more sense.
Hi Maxim,
Thank you for this interesting article.
- For Shebang, I personally prefer using "#!/usr/bin/env bash". It is better for portability, as you cannot be sure to have the bash executable always under /usr/bin.
- I personnaly use exclusively $() instead of backticks, and love the use of curly braces with variables. It is clean and safe.
- An mentionned by Paulo Marcelo Coelho Aragao, I prefer the use double square brackets [[ ]] for conditional test. (Cf. http://tldp.org/LDP/abs/html/testconstructs.html#DBLBRACKETS)
- For clarity, in scripts, always use a usage function that you may call while testing script arguments. Example:
usage() {
echo "Usage: $0 hostName"
echo " hostName: Name of the host to check"
exit 1
}
[[ -z ${hostName} ]] && usage
- It is also a good idea to have your own scripts that help you do thing easily and quickly. I generally put them in a directory that I append to the PATH env variable.
Authored Comments
I think that it depends on your environment.
In my case, I have a lot of VMs. The majority of the VMs are either web servers or app servers. Given that we know exactly what's running inside (JVM with limited heap size, httpd, monitoring tools, ...), we decided to disable swap space and correctly size our RAM.
And I think that in a virtual environment, you already have the overhead of the hypervisor. And as a result swap in such an environment does not speed up things much. So, if you can, it is better to rely on RAM.
On a physical server, swap space may have more sense.
Hi Maxim,
Thank you for this interesting article.
- For Shebang, I personally prefer using "#!/usr/bin/env bash". It is better for portability, as you cannot be sure to have the bash executable always under /usr/bin.
- I personnaly use exclusively $() instead of backticks, and love the use of curly braces with variables. It is clean and safe.
- An mentionned by Paulo Marcelo Coelho Aragao, I prefer the use double square brackets [[ ]] for conditional test. (Cf. http://tldp.org/LDP/abs/html/testconstructs.html#DBLBRACKETS)
- For clarity, in scripts, always use a usage function that you may call while testing script arguments. Example:
usage() {
echo "Usage: $0 hostName"
echo " hostName: Name of the host to check"
exit 1
}
[[ -z ${hostName} ]] && usage
- It is also a good idea to have your own scripts that help you do thing easily and quickly. I generally put them in a directory that I append to the PATH env variable.