launch bash script at startup linux 1

launch bash script at startup linux

crontab -e	// To make a crontab file
@reboot *your shell command here*	// to run at startup

Here is what the above code is Doing:
1. We’re importing the os module, which will give us access to the os.system() function.
2. We’re importing the time module, which will give us access to the sleep() function.
3. We’re defining a function called restart_program().
4. We’re using the os.system() function to run the command “shutdown /r /t 1” which will restart the computer.
5. We’re using the time.sleep() function to wait for 1 second before running the restart_program() function.
6. We’re calling the restart_program() function.

Similar Posts