Setting up a Godaddy cron job to run a PHP script

Can you help me set up cron on godaddy web hosting? I have a php file that I need to run, it is in the cron subdirectory (so the address is http://test.com/cron/file.php ). What do I need to write in the command input field, so this file is running?

+6
source share
10 answers

NOTE. GoDaddy transferred all hosting packages to cPanel. Below are detailed instructions for the older GoDaddy interface. The team is still the same.

At the time of this writing on GoDaddy's shared hosting, I could NOT use the following commands: ping, curl, nc, lynx

but i could use: wget

I successfully created a cron job using wget to load a PHP file containing a mail() call.

  1. log in to your GoDaddy account
  2. click to expand the "Web Hosting" section and find the server you need
  3. click the "Manage" button (previously it was called "Launch")
  4. on the "Hosting Information" page in the "Tools" section, click the "Cron Job Manager" button
  5. on the Cron Task Manager page, click the Create Cron Task button
  6. enter the name you want and select a frequency (1 hour - most often allowed EDIT: GoDaddy added 15-minute increments to the frequency selection.)
  7. enter the command below (with your information):

wget http://YOUR_DOMAIN/YOUR_PATH/YOUR_PHP_FILE.php >/dev/null 2>&1

edit: as Leandro noted, this is a method that allows the cron task to call a remote or local resource - see the GoDaddy documentation if you want to call the resource only locally (which is also safer if you perform more confidential tasks))

in the code "YOUR_PHP_FILE.php" all the actions you want to perform and enable the mail() call (or whatever mail method you would like to use if you configured it correctly).

Using mail() , the SMTP relay server will already be correctly configured in the "php.ini" file: relay-hosting.secureserver.net - which can be confirmed with phpinfo() .

+27
source
 php_path -q file_name_with_absolute_path /usr/bin/php -q /home/[user name]/public_html/test.php 

1: How to find out your php_path?

 echo exec('whereis php'); 

2: How to find out the absolute path of your file?

 echo dirname(__FILE__); 
+4
source

Your cron job command should look something like this: (if your directory structure is no different, of course):

 /web/cgi-bin/php5 "$HOME/html/sendy/scheduled.php" > /dev/null 2>&1 

Regrads

Shahana

+3
source

Configuring Cron for GoDaddy Shared Hosting Accounts Using Cpanel.

* β†’> Cron works in the GoDaddy time zone in Arizona. Go Daddy does not publish anything.

Example: Running cron every day at 1305 (1:05 ​​pm) Pacific Standard Time.

5 14 * * * / usr / local / bin / php -q / home / username / public_html / scriptname.php

+3
source

If you use Godaddy, this should solve your problem.

  * * * * * /usr/local/bin/php /home/path/to/your/file.php > /dev/null 
+2
source

Use for example CURL or wget or lynx .

 lynx -s http://link.to/script.php 
+1
source

You can configure cron jobs through the hosting control center. Check out the official GoDaddy page here: https://www.godaddy.com/help/create-cron-jobs-3548 for help setting it up.

+1
source
 /usr/local/bin/php -q /home/[user name]/[path to the file] 

Link

+1
source

In Godaddy Linux hosting. I used this command to complete a cron job.

 /usr/bin/php public_html/now your path 
+1
source

If you want to run cron in Godaddy. You can find the next team, it will definitely help you.

 php -f /home/[user name]/[path to the file] 
0
source

Source: https://habr.com/ru/post/898918/


All Articles