DEV Community

Discussion on: This article has 61 positive reactions and 24 comments

Collapse
 
hasnaindev profile image
Muhammad Hasnain

Could you please tell me how you run a cronjob in PHP? JavaScript is easy, you run an app and it is like a software. PHP runs only when a user or some external event hits an endpoint to trigger all the code? Please, correct me if I'm wrong. Thanks!

Collapse
 
nilamo profile image
Alex Winfield

phpcli is bundled and enabled by default with all php installations, allowing php files to be executed via the command line just like any other interpreted language, and thus can be added to a crontab.

Collapse
 
hasnaindev profile image
Muhammad Hasnain

Thank you Alex!