Startup-script doesn't work with python file
See original GitHub issueHi 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:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thks all for helping. It worked.
Great! Have fun then.