How to Deploy the Flask app in Ubuntu crontab

Manivannan Murugavel
2 min readDec 14, 2018

--

In my previous story I demonstrated, how to deploy the flask app as ubuntu service and, link here.

Now I will explain how to create a login app using flask python and deploy to crontab. When you start the machine it’s automatically deployed and you can hit your url in web browser.

I have uploaded the full source code in github, please click here to open the github.

Download the github repository in which I have created the two login forms.

i) Implemented with Form Action(POST method)
ii) Implemented with Ajax call (POST method)

Once you cloned the repository, please follow the bellow steps.
i) Set the command “#!/usr/bin/python3” to your app.py in first line
ii) Change the executable permission to your app.py

~$ chmod +x app.py

Once you completed the above steps follow the below steps.

Running job at startup (boot time)

You need to use special string called @reboot. It will run once, at startup after reboot command.

Open the crontab:

~$ crontab -e

Open one editor and paste the below command in last line.

@reboot /home/manivannan/flask-in-crontab/app.py

If your app.py is not executable and you did not set the command “#!/usr/bin/python3” in app.py , please follow the below command.

@reboot /usr/bin/python3 /home/manivannan/flask-in-crontab/app.py

--

--

Manivannan Murugavel
Manivannan Murugavel

Written by Manivannan Murugavel

Artificial Intelligence and Data Science

No responses yet