
$ crontab -eĪt the bottom of this file, add the line: python3 /bin/python_test_code.py &

Now create a cron job scheduler that will periodically handle the execution of the above-created Python script (In this case during system startup). Let us move the script using the mv command. One such viable directory, in this case, is /bin. Next, move the Python Script to a directory where it can be executed with root user privileges upon system restart. Inside this file, we should find the text This LinuxShellTips Tutorial Actually worked! together with the date and time of its creation. Upon rebooting our Ubuntu system, the above Python script should be able to create a file called i_was_created.txt on the Ubuntu Desktop (Desktop). from os.path import expanduserįile = open(expanduser("~") + '/Desktop/i_was_created.txt', 'w')įile.write("This LinuxShellTips Tutorial Actually worked!\n" + str(())) $ nano python_test_code.pyĪdd the following Python script. For this article guide purpose, we will create and use the following Python script. Step 1: Create Your Python ScriptĬreate your Python script if it does not already exist. The following steps will help us achieve the main objective of this article. Running a Python Script at Startup in Ubuntu


The reputation of Python as a programming language speaks for itself.
