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

2 Answers 2

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 
Sign up to request clarification or add additional context in comments.

Comments

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'); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.