Running CasperJS from cron

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

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

This is simple.sh

#!/bin/bash

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

I also added the export to users' .bash_profile file, but cron sent me an email with

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

Not sure what else to do! Any tips?

+5
source share
2 answers

A call .shusing casperjs, which runs only files, .jsor .coffeewill not be sure about fork. I think you can configure your cronjob more directly as follows:

* * * * * PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs /usr/local/bin/casperjs /var/www/javascript/uat/prime.js 2>&1
+12
source

I had a similar problem, I wrote phantomjs and casperjs in .bashrc just like you did, and then set cron like this

* * * * * source ~/.bashrc; casperjs /var/www/javascript/uat/prime.js 2>&1

It worked for me.

0
source

All Articles