Hello, i’ve been trying to run a cron job with a worker component.
This is my code:
while true; do echo “=> Running scheduler” cd core && php artisan booking:sync || true; echo “=> Sleeping for 300 seconds” sleep 300; done
My artisan is inside a folder called core, the first time it works, but the second time i get an error of course because it’s already inside core folder. Is there a way to execute the cd core only once?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Yes, that’s the right solution. You can move the
cd coreout of the while loop so that it’s only run once:
We recently launched Scheduled Functions (it’s in beta currently) which accomplishes what you’re looking to do. Scheduled Functions are not yet supported via App Platform Function components, so you would need to create a stand-alone Cloud Function which calls the API of your App Platform Service. Alternatively, you can do whatever work you need to do inside the function as long as it is within the runtime length limits of Functions (15 min max).
Hope this helps,
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Sign up now