0

I have created a website: http://instapromobiz.com that automates Instagram likes/follows/unfollows via Instagrams api mainly using javascript and a little php.

My issue is that clearly it only runs while the user has the page open. This may be a broad question, but what would be the best way to have this script(which is an infinite loop until the user stops it) run without the user having the page open. Basically they log on, add tags and press start, then they can leave, then come back later and stop the script.

I have regular web hosting, no SSI or VPS, so node.js can't be used.

user3513071
  • 161
  • 1
  • 3
  • 10
  • 5
    "regular web hosting" if that means a shared host, they they are unlikely to let you this –  Jul 31 '14 at 23:25
  • You will have to either write a daemon that runs on the server, or set up a job-scheduler (like Cron) that periodically calls a program/script. If you use "regular web hosting" then you will most likely not be able to do either. – Sverri M. Olsen Jul 31 '14 at 23:35

2 Answers2

-1

Rrestructure your script to terminate, and then use cron to run it every minute or every 15 min. Many web hosting plans will support this type of configuration.

More info on Cron: https://help.ubuntu.com/community/CronHowto

JasonS
  • 199
  • 9
  • This seems like a great idea, but each script is unique to each user, username, tags, likes, follow are all stored in a database. Will I have to create a cron for every user? I'm using godaddy and they have a nice gui for creating crons. – user3513071 Jul 31 '14 at 23:48
  • no loop through the users in the script, and please note GoDaddy is one of the worst hosts ever. –  Aug 01 '14 at 00:25
  • No need to create an individual cronjob for each user. The general idea is to write a script that loops through every user, does whatever you want it to do and marks each set of changes complete so the next time it runs it only has to do new items. If you had more specifics, I would give you more direction. – JasonS Aug 01 '14 at 03:26
-3

You can accomplish this in PHP versions 4 and 5.

Step 1. Remove the time limit

Use the set_time_limit function, and call this:

set_time_limit(0);


Step 2. Ignore the abort

PHP has a friendly function called ignore_user_abort. Use it like this:

ignore_user_abort(true);

Now, the script can run forever!

Bailey Herbert
  • 410
  • 2
  • 8
  • 5
    just doing this alone is a great way to crash the server –  Jul 31 '14 at 23:27
  • The developer should be able to handle that: they can make sure that the process runs only when appropriate, and only if the process is not already running. This solution does exactly what OP asked. – Bailey Herbert Aug 01 '14 at 00:15