Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How would I automatically run a script after the apt-get actions dist-upgrade, install, remove and purge? Is there a suitable way of hooking into the APT lifecycle and run a custom script?

share|improve this question
    
Why don't you use aliases or include apt-get in a/your custom script ? –  user55822 Oct 20 '12 at 8:21
    
Thanks for this question. I want to know how too –  Suhaib Oct 20 '12 at 14:51
    
I'm looking for this answer too, except with apt-get update. @user55822, one reason would be because aliases only apply to your personal bash sessions. Therefore, anything besides you actually running apt-get update in a terminal (e.g. the update cron job, synaptic, etc.) won't make your script run. –  strugee Mar 20 '13 at 4:33

1 Answer 1

up vote 3 down vote accepted

You can automatically run a script by creating a new file /etc/apt/apt.conf.d/99ownscript containing:

DPkg::Post-Invoke {"/bin/bash /path/to/script.sh"; };

Note that this file does not have to be executable, just 644 mode is sufficient.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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