Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:07:43+00:00 2026-06-03T06:07:43+00:00

I have an EC2 instance running an AMI based on the Amazon Linux AMI.

  • 0

I have an EC2 instance running an AMI based on the Amazon Linux AMI. Like all such AMIs, it supports the cloud-init system for running startup scripts based on the User Data passed into every instance. In this particular case, my User Data input happens to be an Include file that sources several other startup scripts:

#include
http://s3.amazonaws.com/path/to/script/1
http://s3.amazonaws.com/path/to/script/2

The first time I boot my instance, the cloud-init startup script runs correctly. However, if I do a soft reboot of the instance (by running sudo shutdown -r now, for instance), the instance comes back up without running the startup script the second time around. If I go into the system logs, I can see:

Running cloud-init user-scripts
user-scripts already ran once-per-instance
[  OK  ]

This is not what I want — I can see the utility of having startup scripts that only run once per instance lifetime, but in my case these should run every time the instance starts up, like normal startup scripts.

I realize that one possible solution is to manually have my scripts insert themselves into rc.local after running the first time. This seems burdensome, however, since the cloud-init and rc.d environments are subtly different and I would now have to debug scripts on first launch and all subsequent launches separately.

Does anyone know how I can tell cloud-init to always run my scripts? This certainly sounds like something the designers of cloud-init would have considered.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:07:45+00:00Added an answer on June 3, 2026 at 6:07 am

    In 11.10, 12.04 and later, you can achieve this by making the ‘scripts-user’ run ‘always’.
    In /etc/cloud/cloud.cfg you’ll see something like:

    cloud_final_modules:
     - rightscale_userdata
     - scripts-per-once
     - scripts-per-boot
     - scripts-per-instance
     - scripts-user
     - keys-to-console
     - phone-home
     - final-message
    

    This can be modified after boot, or cloud-config data overriding this stanza can be inserted via user-data. Ie, in user-data you can provide:

    #cloud-config
    cloud_final_modules:
     - rightscale_userdata
     - scripts-per-once
     - scripts-per-boot
     - scripts-per-instance
     - [scripts-user, always]
     - keys-to-console
     - phone-home
     - final-message
    

    That can also be ‘#included’ as you’ve done in your description.
    Unfortunately, right now, you cannot modify the ‘cloud_final_modules’, but only override it. I hope to add the ability to modify config sections at some point.

    There is a bit more information on this in the cloud-config doc at
    https://github.com/canonical/cloud-init/tree/master/doc/examples

    Alternatively, you can put files in /var/lib/cloud/scripts/per-boot , and they’ll be run by the ‘scripts-per-boot’ path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several amazon ec2 instances running Linux AMIs based on fedora and even
I have postgres database running on Amazon EC2 instance. I have few tablespaces created
I've created an Amazon EC2 AMI running CentOS Linux 5.5 and PostgreSQL 8.4. I'd
I have a puppet master server running in a Amazon EC2 instance. I spawn
I have an Amazon ec2 instance running, and I have a non-root user set
I have a django test, on an amazon ec2 instance, I see the It
I have an EC2 instance running IIS7 + 2008 R2 SQL database on an
I have created an Amazon EC2 Instance that provides Windows Server 2008 with SQL
I have a domain at OVH that links to my EC2 instance like this:
we have a large ec2 instance running in asia pacific region.we want to reserve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.