3

I just started to use phantom js ... I want to do some tasks on specific time interval, like capturing screens of my website every 5 min .

I understand lots of phantom js scripts require some sort of task scheduling tool .. like cronjob ... so I thought I'll get tons of options by searching google but I got nothing useful.

I've seen some run it by using simple setInterval on a nodejs server (phantomjs-node lib) but according to this answer

https://stackoverflow.com/a/15746154/590589 its not very reliable

So it's either very obvious and easy solution so no one is writing about it! or there are not many options.

Either way I'll be thankful for any suggestion

Community
  • 1
  • 1
max
  • 3,614
  • 9
  • 59
  • 107

2 Answers2

2

Just add to cron a task like this

*/5 * * * * /usr/bin/phantomjs /path/to/script.js

Of course, your location of PhantomJS may be different. Check with

which phantomjs
Vaviloff
  • 16,282
  • 6
  • 48
  • 56
1

For task scheduling, have a look at Agenda. You can do something like this

    agenda.define('capture screen', function(job, done) {
      // Do something
    });

    agenda.processEvery('5 minutes');
Trung
  • 1,372
  • 2
  • 14
  • 21