How to Run a PHP Cron Job

PHP is a computer programming language used by many websites. Using PHP provides webmasters with the freedom to create custom programming for the website. This programming allows the website to function more like a piece of software than like an electronic document. Many PHP scripts have files that must be launched periodically so that changes can take effect on the site. The easiest way to run these files is with the use of a cron job, which can be configured to automatically execute the PHP file at a specific time.

Instructions

    • 1

      Log into the control panel for your website's hosting account. Accessing the control panel will require you to enter the user name and password associated with your web hosting account.

    • 2

      Scroll down the dashboard of the control panel until you come to the "Advanced" section. Look under the advanced tools until you find an icon labeled "Cron Jobs." Click the cron jobs icon to be taken to the cron job manager.

    • 3

      Enter a default email address. Scroll down to the "Cron Email" section. Enter an email address at which you would like to receive notifications n the event that a cron job is unsuccessful. Use a valid address that is checked periodically, as this notification is the only way to know if there is a problem. Input the email address, then click the button marked "Update Email" to complete the process.

    • 4

      Enter the details for how you wish your cron job to be configured. Scroll down to the section labeled "Add New Cron Job" and use the drop-down menus to select your options. Choose what time you would like the cron job to run, and how often you would like the job to be repeated. Cron jobs can be set to automatically repeat every hour, day, month, year or at just about any other time interval you wish to use.

    • 5

      Enter the path to the PHP file that the cron job should execute. This is the direct path on the server to the file that the PHP script needs to run in order to update the site. The specific file name may vary from one PHP script to the next, but the general format of how the file is listed in the cron jobs remains as follows:

      php/home/[your username]/public_html/your-php-file-name.php

      Replace "your username" with the user name associated with the hosting account. Replace "your-php-file-name.php" with the name of the specific file you want the cron job to run.

    • 6

      Review all of the settings to make sure they are correct. If everything looks satisfactory, click the "Add New Cron Job" button to add the cron job to the server's schedule.

Tips & Warnings

  • Cron jobs can be used to effectively automate routine aspects of website maintenance, such as making backups, adding scheduled content, removing expiring content or updating applications used by the website.

Related Searches:

References

Resources

Comments

Related Ads

Featured