Is there a way to launch a cron job in the app platform?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

👋 @john375105

A cron jobs feature is on our roadmap, though I don’t have a public release date as of right now. In the meantime, one option is to run a Worker component that acts as a cron job.

If you needed something the runs continuously you could use a worker with a run command like:

while true; do
    echo "=> Running scheduler"
    php artisan schedule:run || true;
    echo "=> Sleeping for 60 seconds"
    sleep 60;
done
  • @jfriesen

    How this code is supose to be in a github repository as valid for App detection?

    • 👋 @matheusstag

      This code is an example of a triggering Laravel tests. It would be used alongside a Laravel app in a worker component.

      • Thanks for reply.

        I didn’t express myself well, but I found the way.
        Just setup same repository as worker component and change the run command from
        heroku-php-apache2 public/
        to

        while true; do
            echo "=> Running scheduler"
            php artisan schedule:run || true;
            echo "=> Sleeping for 60 seconds"
            sleep 60;
        done
        

        Now I’m wondering what it would be like run php artisan queue:work as the same way. For now, my tests doesn’t work

  • This is a feature we also would like to see. A always running worker is not perfect. Thanks !

  • Is there any date when normal cron job will be available?

    I love using app platform (switched from heroku) - it works like a charm, but it’s a huge drawback that there’s no cron job built in nor there’re no tutorials for using celery in App Platform.

    Would be great to know when you could provide on or another solution.

    Thank you.

Show answer This answer has been marked as resolved by emilmoe.
Submit an Answer