4

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.

2
  • This might be relevant: yum.baseurl.org/wiki/WritingYumPlugins Commented Nov 20, 2015 at 0:30
  • See this answer on Yum post actions. You basically write a small actions file that matches specific packages, general actions, or both, and you point it to your script. Commented Oct 28, 2021 at 2:27

1 Answer 1

2

You can create bash function in .bashrc :

myyumfunction() {
    yum update $1
    myScript.sh
}

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

$ myyumfunction someprogram
2
  • 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. Commented Nov 20, 2015 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. Commented Nov 21, 2015 at 0:52

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.