Search code examples
phplinuxcronphantomjscasperjs

Set cronjob using phantom js


I have create small application using phantom js. However it's working fine in my local (Windows). When i upload source to live (linux) server in cpanel i want to run my js file every minute using cronjob. How can i set up all in server. I have upload source as below.

  1. Phantom js source linux phantom source in /home/my_user/phantom/bin/phantomjs
  2. My js file in /home/my_user/phantom/bin/test.js

I try to set cron like

PHANTOMJS_EXECUTABLE=/home/my_user/public_html/phantom/bin/phantomjs -q /home/my_user/public_html/phantom/bin/test.js

But this is not working. Let me know what is missing in my command or anywhere else. This is different form other PHP cron because i need to run phantomjs application within js file and i want to run js file using cron.


Solution

  • To run a script every minute I would suggest creating a similar cron job:

    * * * * * /home/my_user/public_html/phantom/bin/phantomjs  /home/my_user/public_html/phantom/bin/test.js