Home
Blog
About
Database administration
Operating systems
Development
Links
Following require login:
ScratchPad
Vaguely related to the reason we are using sudo, this is a short note about aliases.
We have ours defined in a setup script called from .bash_profile and by every script, e.g.
# db2ckbkp needs read access to backup files alias db2ckbkp='sudo -i -u ${instanceName} db2ckbkp' # db2diag needs write access to db2dump alias db2diag='sudo -i -u ${instanceName} db2diag'
Where ${instanceName} is set to the name of the local DB2 instance, e.g. db2inst1 (you could also use $DB2INSTANCE).
It's worth remembering that by default aliases are not expanded in scripts.
So you could end up in the situation where the alias is defined but the real command is executed by the script.
The solution is to include the follinwg in your script, or in our case the setup script.
# Make sure scripts expand aliases shopt -s expand_aliases