question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Startup-script doesn't work with python file

See original GitHub issue

Hi all,
I’m trying to create startup script in Compute Engine - in directly way when create VM instance, I want to run command just like in SSH command line. Here my startup script:

#!/bin/bash
sudo python3 /home/minhngc4795/test.py

Here is my test.py file, I want to write line “test” to test.txt file in folder:

#!/usr/bin/python3
file = open("test.txt","w")
file.write("test")
file.close()

When I start VM instance and check /var/log/syslog, it doesn’t return error code or anything, just return 0

Sep  7 10:18:18 startupscript systemd[1]: Starting Google Compute Engine Startup Scripts...
Sep  7 10:18:18 startupscript startup-script: INFO Starting startup scripts.
Sep  7 10:18:18 startupscript startup-script: INFO Found startup-script in metadata.
Sep  7 10:18:18 startupscript startup-script: INFO startup-script: Return code 0.
Sep  7 10:18:18 startupscript startup-script: INFO Finished running startup scripts.

But nothing happens in my folder. I try to figure it out but nothing come up. Pls help me, thks a lot. I’m using Ubuntu 16.04.5 LTS

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Sep 10, 2018

Thks all for helping. It worked.

0reactions
gutcommented, Sep 10, 2018

Great! Have fun then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why python code to run a file on startup is not working?
I want my python file to run if Windows is booted up every single time, so I used this simple code: Background.py (This...
Read more >
Run a script on Blender startup WITH PREFERENCES
I put the script in the startup folder but it doesn't load correctly. The problem is that it uses a CustomProp inside the...
Read more >
Python script doesn't start at boot - Raspberry Pi Forums
Hello I am trying to run a Discord bot on my rasp. I am currently struggling to run the python script on the...
Read more >
Windows does not recognize .py file extension as a Python File
So whenever I save a file with the .py file extension, Windows doesn't show the file type as “Python File” like it should,...
Read more >
Startup Script | PyXLL User Guide
The script runs before Python is initialized, and can therefore be used to set up a Python environment if one doesn't already exist....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found