Is there an idiomatic way in Ubuntu to run a script only the first time a machine is booted? (EC2).
Tell me more
×
Ask Ubuntu is a question and answer site for
Ubuntu users and developers. It's 100% free, no registration required.
|
No. But you might want to place your script in
|
|||
|
|
Create a tracking file when the script runs. If the file already exists, exit the script. |
|||
|
|
|
Combining the first two answers
Assuming you name your script #!/bin/bash FLAG="/var/log/firstboot.log" if [ ! -f $FLAG ]; then #Put here your initialization sentences echo "This is the first boot" #the next line creates an empty file so it won't run the next boot touch $FLAG else echo "Do nothing" fi |
||||
|
|
