I'd like to run a script (let's say myScript.sh) every time a yum update or yum install command is executed.

So if I run yum update someprogram then myScript.sh should be executed right after that. Is this possible?

Currently I could run a script if I put it in the ".spec" file when I build the rpm to install, but we have a lot of packages and I'd like to have this script run everytime any package gets updated. I thought about maybe using a cron job to run it every hour but that doesn't seem like a good idea.


You can create bash function in .bashrc :

myyumfunction() {
    yum update $1

Bash functions that you define in your .bashrc are available within your shell. You can call your function like this:

$ myyumfunction someprogram
  • 1
    This covers the manual call to yum but not things like automatique updates or calls to yum via GUIs for example. +1 anyway because it's a simple and good solution. – lgeorget Nov 20 '15 at 17:12
  • Thanks @shcherbak! It would be difficult for me to try to get other people to use my custom function, but this isn't a bad idea! I might end up having to do this. – Katie Nov 21 '15 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.