Milos911
Milos911

Reputation: 433

Godaddy cron job setup for running php script

can you help me setup cron job on godaddy webhosting? I have php file that i need to run, it is located in cron subdirectory (so address is http://test.com/cron/file.php). What do i need to write in command input field, so this file is runned?

Upvotes: 9

Views: 38625

Answers (10)

aequalsb
aequalsb

Reputation: 4035

NOTE: GoDaddy has been migrating all hosting packages over to cPanel. The itemized instructions below are for the older GoDaddy interface. The command is still the same.

At the time of this writing, on GoDaddy 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 call to mail().

  1. log into your GoDaddy account
  2. click to expand the "Web Hosting" section and find the server in question
  3. click the "Manage" button (it used to be labeled "Launch")
  4. on the "Hosting Details" page in "Tools" section, click "Cron Job Manager" button
  5. on the "Cron Job Manager" page, click "Create Cron Job" button
  6. enter the title you want and select the frequency (1 hour is the most frequent allowed EDIT: GoDaddy has added 15-minute increments to the frequency choices.)
  7. enter the command below (with your info):

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

edit: as noted by Leandro, this is the method to make a cron job call a remote or local resource -- consult GoDaddy documentation if you want to call a resource locally only (which is also more secure if you're running more sensitive jobs)

in "YOUR_PHP_FILE.php" code all the actions you want to be performed and include a call to mail() (or whichever mail method you may want to use assuming you have configured that properly).

By using mail() the SMTP relay server will already be set properly in the "php.ini" file to: relay-hosting.secureserver.net -- which you can confirm using phpinfo().

Upvotes: 28

Sapnandu
Sapnandu

Reputation: 642

If you want to run a cron job in Godaddy. You can find following command, it will surely help you.

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

Upvotes: 0

santosh devnath
santosh devnath

Reputation: 172

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

/usr/bin/php public_html/now your path

Upvotes: 2

Sham Haramalkar
Sham Haramalkar

Reputation: 115

php_path -q file_name_with_absolute_path

/usr/bin/php -q /home/[user name]/public_html/test.php

1: How to know your php_path?

echo exec('whereis php');

2: How to know absolute path of your file?

echo dirname(__FILE__);

Upvotes: 10

user5835542
user5835542

Reputation: 51

Cron Setup for GoDaddy Shared Hosting Accounts using Cpanel.

*-->>Cron jobs run on GoDaddy's time zone in Arizona. Go Daddy doesn't publish this anywhere.

Example: Run cron everyday at 1305 (1:05pm) pacific standard time.

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

Upvotes: 5

James R
James R

Reputation: 379

You can setup cron jobs through the Hosting Control Center. Check out GoDaddy's official page here: https://www.godaddy.com/help/create-cron-jobs-3548 for a how-to on setting it up.

Upvotes: 1

Kamaro
Kamaro

Reputation: 1015

If you are using Godaddy this should solve your issue.

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

Upvotes: 3

Engin Yapici
Engin Yapici

Reputation: 6144

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

Reference

Upvotes: 1

shahana
shahana

Reputation: 41

Your cron job command should look something like the following (unless your directory structure is different of course):

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

Regrads,

shahana

Upvotes: 3

genesis
genesis

Reputation: 50976

Use, for example CURL or wget or lynx.

lynx -s http://link.to/script.php

Upvotes: 1

Related Questions