Python Script deployment on Linux

Last Updated : 28 Apr 2026

In the previous chapter, we completed the Python script (blocker.py) and verified that it runs correctly. Now, the next step is to deploy it so it runs automatically at system startup.

The method for deploying a script at startup depends on the operating system. In this section, we will focus on Linux (and briefly mention Windows).

Procedure

To run a script at startup on Linux, we need to configure an entry in the crontab schedule.

Crontab is a list of commands that are scheduled to run at specified intervals. The term crontab stands for cron table, which defines when and how scripts are executed automatically at regular intervals.

Steps for Python Script Deployment on Linux

Follow the following steps.

Step 1:

Open the crontab with the -e flag. Run the following command on the terminal on Linux.

This will open a crontab file which looks like following.

Script deployment on Linux

Step 2:

Now add the following line to the file and save it.

Script deployment on Linux

Step 3:

Restart the system now. On reboot, our script blocker.py is scheduled to run at system start-up. As of now, we are in working hours. So let's try to open the Facebook on the browser.

Script deployment on Linux

As shown in the above image, the website www.facebook.com is refused to connect. Hence, our script is working fine on the system start-up as the website is refused to connect.