PYWWS - Raspberry pi - Cron at reboot

354 views
Skip to first unread message

Robin Lince

unread,
May 15, 2015, 11:05:41 AM5/15/15
to py...@googlegroups.com
Hi,

I set up a Maplin USB station and managed to integrate this with a raspberry Pi model 2B feeding Weather Underground with rapid fire. However the station is at a remote location and after losing power due to a glitch, the system needs an auto reboot option.

I believe that the Cron system / Daemon can be used to make the PYWWS restart. Currently this is new for me and I am unsure where to begin. 

So does anyone have some ideas or experience on the best way to make PYWWS autostart running on a pi?

Thanks

Jim Easterbrook

unread,
May 15, 2015, 11:19:59 AM5/15/15
to py...@googlegroups.com
On 15/05/15 15:59, Robin Lince wrote:
>
> I believe that the Cron system / Daemon can be used to make the PYWWS
> restart. Currently this is new for me and I am unsure where to begin.
>
> So does anyone have some ideas or experience on the best way to make
> PYWWS autostart running on a pi?

There's more than one way to do it. What I do is to have cron run a
script every 10 or 20 minutes to check that pywws is running, and if it
isn't restart it.
http://jim-easterbrook.github.io/pywws/doc/en/html/guides/livelogging.html#automatic-restarting

This includes additional features such as not starting pywws until NTP
has set the system clock and emailing me part of the log file so I can
see why it crashed. You can leave these bits out initially.
--
Jim Easterbrook <http://www.jim-easterbrook.me.uk/>

Ole Andreas Gløersen

unread,
May 15, 2015, 2:47:36 PM5/15/15
to py...@googlegroups.com
I made Jim's script a little bigger with more parameter possibility.

I add it here.



Regads

Ole Andreas
d_livelog.sh

Brian Orpin

unread,
May 25, 2015, 8:26:55 AM5/25/15
to py...@googlegroups.com

Cron is a tool for regular tasks.  A better tool for something that should always run at startup is to use a daemon.

I created a daemon file that you should find in https://github.com/borpin/pywws-scripts. that needs to go in the /etc/init.d/ folder

Basically as it is in this folder, when the pi starts, it executes all the files in this folder automatically and so it runs the pywws-livelog script at startup.  You will need to edit the file to suit your installation.

Because I am not using cron, I use a package called monit (sudo apt-get install monit) to monitor if pywws is still logging.  If it is not it automatically restarts the daemon.  The advantage here is that you can monitor the daemon (i.e. the script) separately from the actual logging.

This works really well and I have not had any breaks for ages.  I check the logs occasionally and it does show monit occasionally restarting the process.
 
HTH

Brian
Reply all
Reply to author
Forward
0 new messages