-2

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.

5
  • Cronjob should be put into /etc/cron.d/.
    – Daniel W.
    Oct 5, 2016 at 9:18
  • @DanFromGermany i have set cronjob using command in my cPanel, which file i put into etc/cron.d/ and there is no such folder name cron.d into cpanel Oct 5, 2016 at 9:44
  • Why you want to use cpanel?
    – Daniel W.
    Oct 5, 2016 at 10:24
  • Possible duplicate of Run a PHP file in a cron job using CPanel
    – Daniel W.
    Oct 5, 2016 at 10:24
  • Without set cron in cPanel how can i execute file for every minute. I want to run js file with phantomjs application PHP cron file working well. Oct 5, 2016 at 10:39

1 Answer 1

2

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
1
  • OK it's working now. Issue is with my server, it was not execute cron command. Now i moved another server and it's working fine Oct 5, 2016 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.