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

Written by Bala Krishna

Bala Krishna is web developer and occasional blogger from Bhopal, MP, India. He like to share idea, issue he face while working with the code.

This article has 7 comments

  1. John

    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.

  2. Meesh

    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?

  3. Judy Gerard

    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.

  4. CMJ

    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.

Leave a Comment

Your email address will not be published. Required fields are marked *