I would like to start my python script (which in turn uses tornado) on boot or, what may be even better, on restart of Linino so that it will get restarted too if one presses the Yun RST button.
python /www/sd/yun_tests/server.py
I read about making an init.d script. But what should I have to use for the START and STOP values?
What else to put in there?
Thanks. Sound good. Will give it a try.
What exactly do you mean by "restart your yun after you add the crontab to take effect"?
Does it mean to power down or to press the Yun RST button?
Any of the two.... just reset for the crojob to take effect.
Although, in your case the yun would reset anyway for you to see if the cronjob is working since it is something that has to happen in startup so my comment was kinda useless
no idea with the init.d,
Another idea /hack would be to start a crontab with a script running every minute
the script, lets call it check.py will be looking if the server.py is running . If yes it does nothing. If no, it calls server.py
No code from me, but i bet somebody can help, i am just trying to think of ways to do it.
I guesss you can check from the PID like this post suggests:
Did a little search and it looks like one has to start and enable cron first.
Found this on superuser.com:
By default OpenWrt does not enable the cron service. To start it and enable automatic startup during subsequent reboots, you need to execute the following commands:
There is a box at the bottom of the System->Startup page in luci where you put commands to execute at start up. You can edit /etc/rc.local if you prefer, they will do the same thing.
I made a script named test in /root:
#!/bin/ash
touch /root/started
made it executable:
chmod a+x /root/test
make rc.local look like this:
root@Yun:/# cat /etc/rc.local
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
/root/test
exit 0
after I reboot I get:
ls -l
-rw-r--r-- 1 root root 0 Nov 23 11:42 started
-rwxr-xr-x 1 root root 32 Nov 23 11:20 test
showing me the last time I rebooted, a few minutes later I get
ls -l /root
-rw-r--r-- 1 root root 0 Nov 23 11:56 started
-rwxr-xr-x 1 root root 32 Nov 23 11:20 test
This will be the VERY last thing done on startup, you need a little patience, I can actually get a console before the script is run, and see this:
root@Yun:/# ls -l /root
-rw-r--r-- 1 root root 0 Nov 23 11:42 started
-rwxr-xr-x 1 root root 32 Nov 23 11:20 test
root@Yun:/#
root@Yun:/# ls -l /root
-rw-r--r-- 1 root root 0 Nov 23 11:56 started
-rwxr-xr-x 1 root root 32 Nov 23 11:20 test
I have flashed my Yun with a image I compiled from source so there are some details different on my Yun, evidently this is one, I don't have that line in my rc.local.