biwa7636
Posts: 24
Joined: Mon Aug 06, 2012 2:23 pm

Using Crontab to open webpage and schedule R statistic

Fri Aug 17, 2012 5:15 am

I try to use Raspberry Pi to build a dashboard.
I have already set up Pi automatically go the startx, hiding the tool bar and no screen saver. Also can open a html file by Midori at the fullscreen mode, which is already pretty good.
But I have some issues that can't figure out.
1. Since I am using R statistics to generate html file so if I want to update the info on the html file, I need to run a command periodiclly:

Code: Select all

Rscript -e "knitr::knit('filename')"...
2. After updating the html using R, I need to let Midori reload the latest html.
method1: kill the previous midori process then reopen it.
method2:

Code: Select all

midori -e Reload
I want to use crontab to schedule these command, but the problem is that there is something to do with export display.... anyway, I just can't put both of the commands in the crontab easily since they seemed have something to do with GUI or ...
for problem2, I have read I can write: export display=:0...etc...but doesn't work either.
Pure noob to Linux and any help is appreciated!

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: Using Crontab to open webpage and schedule R statistic

Fri Aug 17, 2012 5:19 am

Have you tried or considered putting a content refresh header in the HTML? Or using JavaScript to background load a refreshed document and displaying it when rendered? jQuery, AJAX?
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Using Crontab to open webpage and schedule R statistic

Fri Aug 17, 2012 6:04 am

Or last resort - iframe that points to what you want to view, with a refresh on the page containing the iframe
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

biwa7636
Posts: 24
Joined: Mon Aug 06, 2012 2:23 pm

Re: Using Crontab to open webpage and schedule R statistic

Tue Aug 21, 2012 8:42 pm

jackokring wrote:Have you tried or considered putting a content refresh header in the HTML? Or using JavaScript to background load a refreshed document and displaying it when rendered? jQuery, AJAX?
Hi Dear Jackokring.
I have never tried to change the HTML itself since it is a html file generated by R automatically, I mean it might be easy to put a header or use javascript to refresh the page if you modify the HTML code, but the question is that it is not easy to modify the code automatically. Assume we gonna generate many different HTML files to display, the easiest gonna be use the crontab to cite them one by one and also use crontab to refresh the browser. I am not quite sure how to do that...but thanks for your reply.
If you can let me know how many lines of code will I need to put into the html. I might think about changing the method.
Thanks again!

biwa7636
Posts: 24
Joined: Mon Aug 06, 2012 2:23 pm

Re: Using Crontab to open webpage and schedule R statistic

Tue Aug 21, 2012 8:43 pm

SirLagz wrote:Or last resort - iframe that points to what you want to view, with a refresh on the page containing the iframe
Sorry, Can you be more specific. I can't understand... thanks SirLagz

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Using Crontab to open webpage and schedule R statistic

Tue Aug 21, 2012 9:50 pm

I myself would use a phyton script that loops forever (with pauses between each loop).
It could be automatically started by cron on system power-on and run in the background.

If you are going to do it the JavaScript / iframe route , it'll be only two to three lines of code.

A iframe is a website embedded in another website , the iframe points to a target webpage.
So you'll have two pages : The page containing the iframe (self-made) , and the iframe target. (whatever R outputs)

It was a quite debated way of faking / stealing content back in the 90' s .

I do not know how broad you knowledge of HTML/ JavaScript is , but this should
be a simple google copypasta effort.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Return to “General discussion”