A personal repository of random information in compensation for a fatigued biological computer
Breaded IT » Web Development » Godaddy specific notes
20120818
Cron jobs, passing in parameters to xxx.php
I expected to be able to do something like: /web/cgi-bin/php5 "$HOME/html/_motorcyclepartsconzhosting/backup.tools/silisoftware/backupDB.php?StartBackup=complete&mailto=y"
but we just migrated to Godaddy 4GH servers and that doesn't work..:
http://support.godaddy.com/groups/web-hosting/forum/topic/404-not-found-error-using-cron-job
DaveD said 1 year ago:
@sailpilot
Unfortunately we do not support GET requests through Cron, so you cannot define arguments in the way you have specified. However, it is still possible to process this command through Cron with modification of the script itself and how the command is run. Our administrators suggest that you can define the arguments within the script itself and then include the required values in the command as space delimited parameters. For example:
php5 $HOME/html/script.php?var=value
Becomes
php5 $HOME/html/script.php var value
At which point the $argv array will then contain the values ‘var’ and ‘value’ which can then be utilized within the script. Using this method you can pass parameters to the script as needed. Additional information can be found here:
http://www.php.net/manual/en/reserved.variables.argv.php
JasonP said 12 months ago:
@sailpilot
Additionally, it is helpful to know that in the Go Daddy shared hosting environment, files are added to the “Webroot” (http folder) of the hosting server. As cron jobs are ran on the hosting root, they will not be affected by changes made to the php.ini in the webroot (http) directory.
The php function register_argc_argv is ‘OFF’ by default in our shared 4GH hosting environment. Should this function be required as a portion of your Cron and associated script, this will need to be defined in the Cron itself. This can be accomplished by adding the php flag -d along with the desired function to the Cron command. For example:
-d register_argc_argv=on
Please note that this may not work in all cases and is highly dependent on the script that is in use
Hope this helps!
sailpilot said 12 months ago:
to clarify Jason’s post the required command line in Cron should be something like:
php5 -d register_argc_argv=on $HOME/html/script.php arg1 arg2
in addition I found that I had to declare argv as a global variable in the script for this to work.
If this works as it should the script can pick up the parameters from the command line from the argv array:
argv[0] = script.php
argv[1] = arg1
argv[2] = arg2
and so on.
Wow that seems way too hard, so instead we will just create a shell PHP file to preset the params we require and then call the original script.. then I'll call this script instead:
<?php
$_REQUEST['StartBackup'] = 'complete';
$_REQUEST['mailto'] = 'y';
//$_REQUEST['nohtml'] 'n';
include('backupDB.php');
?>
20120705
URL Canonicalization on Godaddy hosting
In domain root:
in .htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.bucketsnbits\.co.nz$ [NC]
RewriteRule .? http://www.bucketsnbits.co.nz%{REQUEST_URI} [R=301,L]
20111125
What happened:
Issue:
Login error
xxx.com uses cookies to log in users. You have cookies disabled. Please enable them and try again.
Analysis:
Ran PHPInfo() and see that session.save_path has no value
Solution:
session.save_path = "/tmp/";
20111125
What happened:
Issue:
Analysis:
Solution:
upload_tmp_dir = "/tmp/";