Running a PHP file with a cron job

To run a PHP file from cron, use the "cron jobs" section of your control panel. Use the following line and modify it for your account and filename and location:

php -q -f /home/username/public_html/location/script.php

Here are the steps on how to set up a cron job with Ultra Web Hosting:

  1. Log in to your Ultra Web Hosting account.
  2. Click on the cPanel icon.
  3. Scroll down to the Advanced section and click on the Cron Jobs icon.
  4. In the Add New Cron Job section, enter the following information:
    • Minute: The minute that you want the cron job to run. You can use the asterisk (*) to represent all minutes.
    • Hour: The hour that you want the cron job to run. You can use the asterisk (*) to represent all hours.
    • Day: The day of the month that you want the cron job to run. You can use the asterisk (*) to represent all days.
    • Month: The month that you want the cron job to run. You can use the asterisk (*) to represent all months.
    • Weekday: The weekday that you want the cron job to run. You can use the asterisk (*) to represent all weekdays.
    • Command: The command that you want to run. This can be any command that you would normally run from the command line.
  5. Click on the Add Cron Job button.

Once you have added the cron job, it will be scheduled to run at the specified time. You can view your cron jobs by clicking on the Cron Jobs icon in cPanel.

 

Here is an example of a cron job that you could create:

* * * * * /path/to/script.php

 

This cron job would run the script.php script every minute, on the hour, day, month, and weekday.

 

  • 290 Users Found This Useful

Was this answer helpful?

Related Articles

How can I view/modify data in my MySQL database?

There are two ways to view your MySQL database with Ultra Web Hosting: Using phpMyAdmin Go...

phpMyAdmin - Error Incorrect format parameter

When importing a database with phpMyAdmin I receive the error "Error Incorrect format parameter"....

Changing your PHP version

Have you received an error regarding your PHP version? If so, you may quickly and easily change...

When trying to connect to MariaDB or MySQL you receive error 2003 Cannot connect to MySQL on xxxxxx on port 3306 10060

The error 2003 "Cannot connect to MySQL on xxxxxx on port 3306 10060" means that the MySQL...

What is the Path to ImageMagick?

The path to ImageMagick on Ultra Web Hosting is /usr/bin/. This means that you can access...