0

I have setup phantomjs as web server for scraping on AWS EC. I don't know how to run phantoms script forever through putty? Any alternative for phantom like Forever for NodeJS?

shoaib
  • 29
  • 6
  • 2
    The same way like every other linux program? http://stackoverflow.com/questions/2499187/how-to-run-infinitely-script-in-background-on-linux – smentek Apr 06 '16 at 09:33
  • I don't think so, people had any luck with nohup and phantomjs. Like 1: [phantomjs not working with background process nohup](http://stackoverflow.com/questions/31065598/phantomjs-not-working-with-background-process-nohup) and 2: [phantomjs with nohup not working](http://stackoverflow.com/questions/24479576/phantomjs-with-nohup-not-working) – shoaib Apr 29 '16 at 12:14

1 Answers1

3

PM2 is a good option. You can take a look at the documentation, it enables you to automatically restart your program if it crashes, and has a lot of cool features.

To start your PhantomJS application using PM2, the command would be:

pm2 start app.js --interpreter phantomjs

The application will run detached to your SSH session, so you can safely quit your Putty window.

christophetd
  • 3,834
  • 20
  • 33