Permission denied error with godaddy cron job
Cron is a Linux command tool that allows you to schedule tasks unattended at a specified time interval. There are several ways to schedule commands to run. You can run any available command or script like php, perl and shell script as a Cron Job. It run specified command and send output to the user or email id specified in the configuration.
This is common error godaddy user face when they run Cron job first time. The Godaddy Cron Manager only ask for the script file to run. You need to give executable file path separately otherwise php file will be run with shell script and produce permission denied error. To over come this problem you simply need to use php executable path as first argument and full path of the script as second argument. Here is the correct Godady executable path.
Shell: /bin/sh
Perl : /usr/bin/perl
PHP4: /web/cgi-bin/php
PHP5: /web/cgi-bin/php5
Exmple Cron Job:
/web/cgi-bin/php /home/content/youraccount/html/run_cron.php
Thanks for the tip. I was banging my head against the wall to find a way to back up all files in our GoDaddy Hosting account.
Here’s some more info regarding the syntax of running CRON scripts in GoDaddy.
The Command field is the script or executable that runs at a specified frequency. Click Browse to locate a file in your hosting account. The full file name of your selection is placed into this editable field.
Cron commands are typically script files that have executable permission and specify their interpreter as the first line of the file. For example, a first line of “#!/usr/bin/perl” directs the system to run the perl language interpreter for the file.
Your Shared Hosting account supports the following languages and associated interpreter lines:
* Perl: #!/usr/bin/perl
* Python 2.2: #!/usr/bin/python2.2
* Python 2.3: #!/usr/bin/python2.3
* Python 2.4: #!/usr/bin/python2.4
* Ruby: #!/usr/local/bin/ruby
* Bash: #!/bin/bash
The installed versions of PHP 4 and PHP 5 do not support the interpreter specification in a PHP file. In order to run a PHP script via Cron, you must specify the interpreter manually. For example:
* PHP 4: /web/cgi-bin/php “$HOME/html/test.php”
* PHP 5: /web/cgi-bin/php5 “$HOME/html/test.php5”
Note: In this example script, “$HOME” represents the full path to your Shared Hosting account. The actual path to your account will be provided if you select the script from your account using the Browse button.
This is great for shared hosting with GoDaddy, thanks. How about setting up a PHP5 script to run as a cron job on a GoDaddy virtual dedicated linux server? Couldn’t get anything to work except curl.. is there a performance issue when using curl with the full URL path to the PHP file, instead of relative paths of the interpreter and PHP file?
Do you know if you can use sendmail this way? If so, do you know the path? I’ve tried both /usr/bin/sendmail and /web/cgi-bin/sendmail and both failed.
Yeah, I’ve been searching everywhere to try and figure out how to get an asp page to run on a Godaddy virtual server, using the task scheduler in Plesk. I have no idea what the path would be to the executable file.
This didn’t work as expected for me. Stopped working, rather. I found another solution that seems to have worked at http://www.fortasse.com/2010/01/tutorials/tutorial-automatic-backup-script/. Did Godaddy change the way their CRON jobs work?
thank you very helpful
This was really useful. Thanks.