Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running CasperJS from cron

Tags:

casperjs

So, I'm trying to run casperJS as a cron job on my server, this is the crontab:

* * * * * /usr/local/bin/casperjs /var/www/javascript/uat/prime.sh 2>&1

This is prime.sh

#!/bin/bash

export PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs
/usr/local/bin/casperjs /var/www/javascript/uat/prime.js 2>&1

I've also added the export to the users' .bash_profile, but cron emails me with

Fatal: [Errno 2] No such file or directory; did you install phantomjs?

Not sure what else to do! Any advice?

like image 487
Mike Avatar asked Feb 12 '13 15:02

Mike


1 Answers

Calling a .sh with casperjs which only runs .js or .coffee files won't fork for sure. I think you can setup your cronjob more directly like this:

* * * * * PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs /usr/local/bin/casperjs /var/www/javascript/uat/prime.js 2>&1
like image 152
NiKo Avatar answered Oct 13 '22 05:10

NiKo