I tried to run ngrok after boot on raspberry pi by the following way but failed.
Is there any idea to do this?
/home/pi/run_after_boot.sh
##! /bin/sh
ngrok start --all \
--config=/home/pi/.ngrok2/ngrok.yml \
--log=stdout \
> /home/pi/ngrok.log &
I checked ngrok works by manual running of this sh file.
..
..
/home/pi/run_after_boot.sh
exit 0
I checked ngrok works by manual running of this file (/etc/rc.local).
sudo rm /home/pi/ngrok.log
$ sudo reboot
$ sudo less /home/pi/ngrok.log
The log file is created but nothing is written.
$ ps aux | grep ngrok
ngrok does not run.
I also tried the following but the result of logfile is same.
/home/pi/run_after_boot.sh
##! /bin/sh
(sleep 10 &&
ngrok start --all \
--config=/home/pi/.ngrok2/ngrok.yml \
--log=stdout \
> /home/pi/ngrok.log) &
@reboot /home/pi/run_after_boot.sh
$ ngrok -v
ngrok version 2.1.1
$ uname -a
Linux raspberrypi 3.18.7+ #755 PREEMPT Thu Feb 12 17:14:31 GMT 2015 armv6l GNU/Linux
Thanks.
Sorry, it was my failure.
I succeeded in running ngrok after boot with calling it by absolute path.
/usr/local/bin is not included just after boot.
ngrok -> /usr/local/bin/ngrok
A command after modification.
/usr/local/bin/ngrok start --all \
--config=/home/pi/.ngrok2/ngrok.yml \
--log=stdout \
> /dev/null
Thanks.
glad you got it figured out!
Thanks!
I'm trying something similar (or the same).
I want to start ngrok whenever the raspberry boots
this is a script, which has been added to /etc/init.d with update-rc.d startup defaults
you see all the lines commented out. that's all the crap I tried :) nothing really worked...
ngrok however starts and remains for many cases if I login and run the script
#! /bin/sh
# /etc/init.d/ngrok
#screen -D -R
# ngrok tcp 22 > ~/ngrok.out.txt
#ngrok -log=stdout tcp 22 > ngrok.out.txt &
/usr/local/bin/ngrok authtoken I_REMOVED_MYTOKEN >> /home/pi/ngrok.out.txt
#sudo ngrok tcp 22 -log=stdout > ngrok.out.txt &
sudo echo 'init' > /home/pi/ngrok.out.txt
#cd
#screen -D -R
/usr/local/bin/ngrok tcp 22 -log=stdout >> ngrok.out.txt &
#screen -dm ngrok tcp 22
#su - pi -c /usr/bin/screen -dm ngrok tcp 22
sudo echo 'done' >> /home/pi/ngrok.out.txt
#sleep 360
Check out this rep. Clean native solution.
Most helpful comment
Check out this rep. Clean native solution.
https://github.com/vincenthsu/systemd-ngrok