5

I have a web app powered by Laravel that is set up on AWS ECS. I would need to run an artisan command as a cronjob.

I'm looking at "Scheduled Tasks" in ECS Cluster configuration. I can launch new tasks following the "Scheduled Tasks (Cron)" documentation on AWS. I'm using the Laravel's Task Definition in the Target which I use for web services & it has two tasks.

  1. Not sure how I can invoke the artisan command
  2. The scheduled task seems running forever

Any help would be greatly appreciated. Thank you.

Sivaji
  • 101
  • 1
  • 5
  • Hi, if the response below answered your question please upvote and accept it. That's the ServerFault way of saying *Thanks* for the time someone took to help you :) – MLu Feb 19 '19 at 20:51

1 Answers1

7

I'm not familiar with Laravel or Artisan but essentially you'll need to:

  1. create a container image with your job (artisan)
  2. create a task definition that runs the artisan container when invoked
  3. create the cron-scheduler to invoke the above task definition

Regarding "The scheduled task seems to be running forever" - ECS Tasks do their job and exit and are not restarted (e.g. cron jobs). ECS Services are restarted when they exit (e.g. web servers). Make sure you're creating a Task and not a Service. Then it should be running forever.

Hope that helps :)

MLu
  • 24,849
  • 5
  • 59
  • 86
  • Thanks for your response. I think I found the answer from acloud.guru forum https://acloud.guru/forums/aws-ecs-scaling-docker/discussion/-LUjDTjai2ZzvemiVnk6/what_is_the_best_way_to_run_cr – Sivaji Jan 02 '19 at 05:48
  • Looks like AWS System Manager is the way to go... – Sivaji Mar 18 '19 at 08:03