0

I have a python application and I run it using python app.py but when the machine restart for any reason the application stoped

I searched and I found that I can make it run again using corn jobs

so I installed crontab and add the following code to it

@reboot /home/airnotifier/airnotifier/airnotifier.sh

and this is the code in the file airnotifier.sh

cd /home/airnotifier/airnotifier
python ./app.py
cd airnotifier
python ./app.py
cd /home/airnotifier/airnotifier
python app.py
cd airnotifier
python app.py

as you can see, I tried all combinations to make the application run again

can anyone tell me what did I do wrong?

Amira Elsayed Ismail
  • 9,216
  • 30
  • 92
  • 175

1 Answers1

0

I would try to just add this directly to the crontab

@reboot python3 /home/airnotifier/airnotifier/app.py

Unless you're on an older 2.x version of python, you should call it with python3

Kaleb Fenley
  • 216
  • 1
  • 5