3

I am trying to put my script file (script.sh) in the /var/lib/cloud/scripts/per-boot/ directory, so that the cloud-init runs the script every time my VPS boots.

But the problem is the script is not getting executed when the VPS boots. Not even once.

My script file goes like this(this is just a test file)...

#!/bin/sh

echo "Hello User !!!"
mkdir /tmp/test

Is there any mistake I am doing ?

Thanks for your help !

  • 1
    Is your script executable? It won't run if it's not executable. Also, one part of the cloud-init documentation says not to write to `/tmp`. `per-boot` scripts run after `runcmd` but it might be possible the same issue is possible during `per-boot` scripts as well. https://cloudinit.readthedocs.io/en/latest/topics/modules.html?highlight=%2Fvar%2Ftmp#runcmd – falcojr Mar 02 '21 at 17:12
  • Hello, Sorry for the delay in replying, as you said the script file was executable already and also I have edited the script file to make a new demo file( /home/user/user.txt ) in home directory from previous (/tmp/test) dir. But the Cloud-Init is still not able to process my per-boot script even after rebooting. Any other suggestions?? Thanks for Your reply! – Sumeet Boga Mar 11 '21 at 12:51
  • Any luck with this? Im having the same problem – Tom Shaw Jan 25 '22 at 13:42
  • Does this answer your question? [Cloud-init per-boot script doing nothing](https://stackoverflow.com/questions/12240194/cloud-init-per-boot-script-doing-nothing) – Métoule Jun 17 '22 at 14:35

0 Answers0