I want to run a shell script that runs a python program and shutdowns after the program is done. Here is what I wrote
#!/bin/bash python program sudo shutdown -h now
This just shutdowns the system without waiting for the program to complete. Is there a different command to use that waits for the program to complete?
What you have in your example should actually only shutdown once the python command has completed, unless the python program forks or backgrounds early.
Another way to run it would be to make the shutdown conditional upon the success of the first command
python command && sudo shutdown -h now
Of course this still will not help you if the python program does anything like forking or daemonizing. Simply try running the python script alone and take note if control returns immediately to the console or not.
Answered By – jdi