# Chefonic way to do apt-get update

**URL:** <https://discourse.chef.io/t/chefonic-way-to-do-apt-get-update/2892>\
**Category:** Chef Infra (archive)\
**Created:** [June 30, 2012, 1:21pm UTC](https://discourse.chef.io/t/chefonic-way-to-do-apt-get-update/2892 "2012-06-30T13:21:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Montgomery](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@David\_Montgomery](https://discourse.chef.io/u/David_Montgomery)\
**Post date:** [June 30, 2012, 1:21pm UTC](https://discourse.chef.io/t/chefonic-way-to-do-apt-get-update/2892/1 "2012-06-30T13:21:26Z")

</div>

Hi,

what is the chef way for running apt-get update in a recipe?

for now I am using:

execute “apt\_update” do  
command "apt-get update"  
action :run  
end

---

<div class="post-metadata">

**Author:** ![Larry\_Wright](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/larry_wright/32/177_2.png) [@Larry\_Wright](https://discourse.chef.io/u/Larry_Wright)\
**Post date:** [June 30, 2012, 1:31pm UTC](https://discourse.chef.io/t/chefonic-way-to-do-apt-get-update/2892/2 "2012-06-30T13:31:24Z")

</div>

I'm not sure what you're goal is with that, but if it's just to ensure that it's run regularly, check out the Opscode apt cookbook: [GitHub - sous-chefs/apt: Development repository for the apt cookbook](https://github.com/opscode-cookbooks/apt)

It ensures that apt-get update is run at least once per day.

--  
Larry Wright  
Argonaut Labs, LLC

> **[ArgonautLabs.com is For Sale | BrandBucket](https://www.brandbucket.com/names/argonautlabs?source=ext)**
>
> Buy the domain name ArgonautLabs.com and launch your business with a premium domain and a high quality logo.

On Saturday, June 30, 2012 at 8:21 AM, David Montgomery wrote:

> Hi,
> 
> what is the chef way for running apt-get update in a recipe?
> 
> for now I am using:
> 
> execute "apt\_update" do  
> command "apt-get update"  
> action :run  
> end

---

<div class="post-metadata">

**Author:** ![sme](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/sme/32/271_2.png) [@sme](https://discourse.chef.io/u/sme)\
**Post date:** [June 30, 2012, 11:44pm UTC](https://discourse.chef.io/t/chefonic-way-to-do-apt-get-update/2892/3 "2012-06-30T23:44:11Z")

</div>

Nothing wrong with an execute, but the apt cookbook will do this for you as  
mentioned.

Then within any other resource def you can use notifies like:

notifies :run, resources(:execute =\> "apt-get update"), :immediately

Notice that it's calling 'apt-get update' (no dash) and not  
'apt-get-update' (with dash), which is also defined in by the apt  
cookbook.

-sme

On Sat, Jun 30, 2012 at 6:21 AM, David Montgomery \<[davidmontgomery@gmail.com](mailto:davidmontgomery@gmail.com)

> wrote:

> Hi,
> 
> what is the chef way for running apt-get update in a recipe?
> 
> for now I am using:
> 
> execute "apt\_update" do  
> command "apt-get update"  
> action :run  
> end
