iOSNoob iOSNoob - 2 years ago 534
Linux Question

Starting ngrok and python app on startup

I am currently running ngrock and a python app concurrently on a specific port to text my raspberry pi, and have it respond accordingly to my message via Twilio. Each time my raspberry pi boots up, or reboots, I need to manually start the services again with

./ngrok http 5000
python /path/to/file/
. To avoid that, I edited my cron jobs as follows, and wrote a script called
. However, it doesn't seem to be functioning properly, as I do not receive answers to texts after reboot. Any ideas?


# m h dom mon dow command
*/5 * * * * python /rasp/system/
@reboot python /Rasp/system/twilio/ &

import os
os.system('/./ngrok http -subdomain=ABC123 5000')
os.system('python /Rasp/system/twilio/starter/')

Answer Source

After multiple failed attempts I have seem to come up with a working system. I first had to authorize the root user to use my ngrok account by doing the following:

sudo su
./ngrok authtoken {{Insert Your Auth Token Here}}

Then, I created and as shown.


cd /
./ngrok http -subdomain={{My Reserved Subdomain}} 5000 &
cd /


cd /Storage/system/twilio/starter
python &
cd /

Then, I modified the file permissions so they would be able to be run on startup sudo chmod 755 && sudo chmod 755 Lastly, I edited the Cron Jobs as follows:


# m h  dom mon dow   command
*/5 * * * * python /SKYNET/system/
@reboot sh /Storage/ >/Storage/logs/cronlog 2>&1
@reboot sh /Storage/ >/Storage/logs/cronlog 2>&1

Then after running sudo reboot, the system restarted and I received a response to my sms from the python app.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download