Page 1 of 1

Using Crontab to open webpage and schedule R statistic

Posted: Fri Aug 17, 2012 5:15 am
by biwa7636
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!

Re: Using Crontab to open webpage and schedule R statistic

Posted: Fri Aug 17, 2012 5:19 am
by jackokring
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?

Re: Using Crontab to open webpage and schedule R statistic

Posted: Fri Aug 17, 2012 6:04 am
by SirLagz
Or last resort - iframe that points to what you want to view, with a refresh on the page containing the iframe

Re: Using Crontab to open webpage and schedule R statistic

Posted: Tue Aug 21, 2012 8:42 pm
by biwa7636
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!

Re: Using Crontab to open webpage and schedule R statistic

Posted: Tue Aug 21, 2012 8:43 pm
by biwa7636
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

Re: Using Crontab to open webpage and schedule R statistic

Posted: Tue Aug 21, 2012 9:50 pm
by ghans
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