What is Cron Job in PHP?
After reading this blog you will have answer for your questions like
How to run PHP script automatically? How to schedule a PHP script?
Cron job a task performed by your server. As you know when we want to run a script in PHP we have to lead a page and according to when the page is loaded the script starts running. If you want to perform a fix job on a particular day or set a routine of tasks at a particular time. Practically you cannot load a page every time to run the script. You don’t have any option in backend thru which to can a script automatically. So, the solution is a cron job. The cron job performs a job for you. It runs a script based on a fixed time or routine. Suppose you want to run a job in every half an hour. So for that, you just need to create a separate page and write down your script on to that PHP page. Assign a job to a cron job that runs this particular page (you have to assign a path) in every half an hour. A Cron job is located in your Cpanel. If you don’t find this option in your Cpanel you can switch to third party website. The server will open the file for you according to the schedule and when to page will load in backend your script will run automatically. So you don’t have to open the page manually, the cron job will do this work for you at no extra cost. As PHP is a server side language so I can’t not work offline but which features cron job, you can run a script when you are offline. The script will run automatically. After reading this blog you have an answer for your questions like, How to run PHP script automatically? How to schedule a PHP script? In personally use Go Daddy as it is reliable, awesome customer support and affordable plans along with many features. In Go Daddy, you don’t even have to do coding for using Cron Job.
You just have to select the options. And assign a path of your file and you are ALL SET! Go Daddy Syntax for Cron Job Is /usr/local/bin/php -q /home/[user name]/[path to the file]
Some awesome uses of Cron jobs are
- Send SMS & Email automatically.
- For Bulk SMS & Email (List to the database and send to limited people at one time and send it to multiple times. Like: you have to send mail to 1000 Email it’s difficult to do it in one shot. Set LIMIT and send 20-30 in every 15minutes or accordingly.
- Sending reports
- Shoot Multiple Email & SMS on Form Fill (Save that data and send “thank you” message to the user. Later send SMS & Email and keep changing the send status in MySQL.
Related Topics: