0

I have an application deployed on AWS on a linux instance running LAMP. Programming language of choice is PHP.

I have a process or a function that needs to be executed every 30 mins. What is the best way to achieve this?

In an IIS environment, I would be able to create a scheduled task, but was looking to see if I can get a serverless solution since I am using AWS.

an example is: I have a script that can be accessed via http://. 30 mins goes to http://someurl.com/function the URL request should respond with a JSON with either success or fail, if fail with proper error.

Any help is appreciated.

Rick

Rick
  • 555
  • 1
  • 12
  • 30
  • 2
    you tagged this question with **cron** so you know the answer already –  Mar 21 '16 at 23:51
  • can cron be setup to be serverless? trying to avoid using the same EC2 instance to setup a cron job. thus the question. – Rick Mar 21 '16 at 23:54
  • "can cron be setup to be serverless" so what is it you want to be runing the code if not a server? –  Mar 21 '16 at 23:56
  • if the script is on a particular instance, that is where the cron job should be - why would you want it else where –  Mar 21 '16 at 23:57
  • the script or function can also be accessed via port http on port 80. let me rephrase can I setup a scheduler that will execute a script without having to setup on an instance? – Rick Mar 22 '16 at 00:04
  • it would have to run on *something* that was always *on* you could use your home pc if you really wanted to. Or any other server you own. still baffled why not the server its on, and making the script publicly accessable could be dangerous. –  Mar 22 '16 at 00:05
  • Scheduled AWS Lambda tasks? You aren't using PHP for that though. – Mark B Mar 22 '16 at 00:09
  • thank you both. learning something new all the time. I may be overthinking, if the instances auto scale and if it scales to be 2 servers, does that mean the cron is then duplicated and potentially 2 cron jobs would be running? – Rick Mar 22 '16 at 00:26
  • Cron jobs and autoscaling generally don't mix. Either you will get multiple cron jobs firing, or you will have none firing when the autoscaling group decides to delete the instance with the cron job. I'd recommend looking into Lambda scheduled tasks. If all you need to do is ping a URL every 30 minutes, that would only be a few lines of NodeJS or Python. – Mark B Mar 22 '16 at 00:40
  • Also, as a fairly cheap alternative, you could just spin up a separate t2.nano instance for your cron jobs. That wouldn't cost very much at all, but Lambda would still be cheaper. – Mark B Mar 22 '16 at 00:41
  • @MarkB thank you for the suggestion, I was looking at Lambda, they have quite a few blueprints. I am looking at the microhttps one, but unfamiliar with the setup... do you have any tutorials you would recommend? – Rick Mar 22 '16 at 00:53

0 Answers0