1

I have a startup-script that works well when I launch a compute engine on google cloud. Nevertheless it doesn't seem to execute the following command. echo ${path} > ~/pd.txt Actually I can't retrieve my file when I look for it at the indicated path. Do you have any clue on how I could save a file during startup-script ?

kiki
  • 563
  • 4
  • 17

1 Answers1

4

When startup scripts run on GCE, they run under the root account.

The value of ~ depends on the user. Therefore for startup scripts ~ is /root. If you login with the user name bob.jones then ~ is /home/bob.jones.

You will find the results of echo ${path} > ~/pd.txt located at /root/pd.txt

A couple of tips with start scripts:

  1. Do not expect $PATH to exist. Always specify the full path for both programs and filenames.
  2. Do not use environment variables.
  3. Do not use ~. In your example specify the output filename full path.
John Hanley
  • 74,467
  • 6
  • 95
  • 159