Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running casperjs per cronjob on heroku

I have created an application in casperjs which scraps sport data from a website.

I would like to run this application per cronjob on heroku, to save the sports results in a csv, database or external google docs(haven`t decided yet).

However, I have one questions before I start to implement it for heroku:

  • I found this buildpack for heroku, which claims that it can run casperjs scirpts. However, do I need nodejs to run the script scheduled? Or can I just create a cronjob on heroku?

I really appreciate your replies!

like image 828
Carol.Kar Avatar asked Sep 29 '22 18:09

Carol.Kar


1 Answers

You most definitely can run your script as a Cron job on heroku.

Step 1 - Create the app using the buildpack mentioned :

heroku apps:create myapp --stack cedar --buildpack http://github.com/misza222/heroku-buildpack-casperjs.git

Step 2 - Add scheduler and log addons :

heroku addons:add logentries
heroku addons:add scheduler

Step 3 - open the scheduler :

heroku addons:open scheduler 

or use the dashboard, click My Apps > General Info > Addons > Scheduler

Step 4 - Setup your cronjob :

./vendor/casperjs/bin/casperjs myCasperScript.js

and choose the frequency you want your script to run at.

Hope it helps!

like image 164
xShirase Avatar answered Oct 11 '22 13:10

xShirase