Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 8 of 8

This is a discussion on Error produced by Cron job in the Shared & Semi-Dedicated forum
Hi Developers, I've installed Moodle in my website and this package had setup a cron job, but it is producing an error that i receive ...

  1. #1
    JPC Member
    Join Date
    Oct 2004
    Posts
    10

    Error produced by Cron job

    Hi Developers,

    I've installed Moodle in my website and this package had
    setup a cron job, but it is producing an error that i
    receive in my e-mail account:

    Cron <myusername@nameofjaguarserver> wget -q -O /dev/null
    http://nameofjaguarserver.nocdirect....admin/cron.php

    /bin/sh: line 1: /usr/bin/wget: Permission denied

    What does means this error?
    and
    How did i solve this?

    Thanks in advance.

    alejandro

  2. #2
    || $name ne 'R.Stiltskin'
    Join Date
    Jun 2003
    Location
    Tejas
    Posts
    2,438
    I've not run straight command line scripts for shared server crons. I was under the impression that any cron job needed to be run from a typically *.cgi or *.php script (accessible by a LWP request from the server) where the server makes a request and the script runs on its own, non-interactively, to completion. Have you tried placing your snippet into a script and run it via PHP or CGI?

    Unless someone mentions otherwise, you may need to do this.

  3. #3
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Alejandro,

    Are you trying to set this up from the command line (SSH)? You may have to do it with the cron job tool in CPanel. If you are able to do it from the command line (I've not tried here at JPC), you'd need to be using the contab command, not "cron." "cron" is the name of the deamon process (the background service that watches for cron jobs that need to be run), crontab is the tool used to set those processes up. I suspect that may be the cause of your error.

    Spathy,

    You can set anythink that you can run from an SSH session to run as a cron job. It is actually better to do this from a security standpoint, especially if you are doing anything sensitive. For example, say you wnated to run a script to charge credit cards (such as Jag would do) overnight. I'm much rather have the cron job run from a script that doesn't "touch" the web directly. I'd hate to have someone find that web URL and exploit it.

    Actually, what Alejandro is trying to do here is run a web script. Since cron is used to run server scripts (not websites), you need to use wget to call the web script if you are running it that way. wget simply downloads a web page. In the case of calling a cgi or php script, it causes the server to execute the script and send its output.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  4. #4
    JPC Member
    Join Date
    Oct 2004
    Posts
    10

    wget error

    Quote Originally Posted by jason
    Alejandro,

    Are you trying to set this up from the command line (SSH)?
    No, the installation of Moodle set up this cron job automatically.


    Quote Originally Posted by jason
    You may have to do it with the cron job tool in CPanel. If you are able to do it from the command line (I've not tried here at JPC), you'd need to be using the contab command, not "cron." "cron" is the name of the deamon process (the background service that watches for cron jobs that need to be run), crontab is the tool used to set those processes up. I suspect that may be the cause of your error.
    Actually, what Alejandro is trying to do here is run a web script.
    Oh... a web script. So this line points to a Moodle web script:

    http://nameofjaguarserver.nocdirect....admin/cron.php

    Quote Originally Posted by jason

    Since cron is used to run server scripts (not websites), you need to use wget to call the web script if you are running it that way. wget simply downloads a web page. In the case of calling a cgi or php script, it causes the server to execute the script and send its output.

    --Jason
    wget downloads the php script and execute the script
    so the real cause of error is reported in this line:

    /bin/sh: line 1: /usr/bin/wget: Permission denied



    Why is denied the permission to execute this php script???

    How could i change the permissions for wget???

    Where is the folder: /usr/bin/wget???

    Is this a folder in my account or a server wide setting
    that only server administrators could change???

    Thanks a lot Jason, for answering these questions

    alejandro

  5. #5
    || $name ne 'R.Stiltskin'
    Join Date
    Jun 2003
    Location
    Tejas
    Posts
    2,438
    Quote Originally Posted by jason
    You can set anythink that you can run from an SSH session to run as a cron job. It is actually better to do this from a security standpoint, especially if you are doing anything sensitive. For example, say you wnated to run a script to charge credit cards (such as Jag would do) overnight. I'm much rather have the cron job run from a script that doesn't "touch" the web directly. I'd hate to have someone find that web URL and exploit it.
    Thanks for the correction and the info. It sure makes my life easier knowing that I may now simplify my cron jobs like I do for servers that are completely under my control. Security wasn't so much of an issue since I restrict them to run only if a particular IP requests it, in this case that of the server, and send an email to me when it runs to confirm that it is behaving nicely. I guess one could spoof the IP... hmmmm.

    Alejandro,
    The host may have chmod the wget program to limit its access. Rather than accessible by "others" or "nobody", it's owned by root and execution tightly controlled even though it can be found in the path you defined. If that is the case, you may need to submit a ticket to support and see what options you have. I'm guessing they want to contain the possibility of rogue downloads.

  6. #6
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    I misread your first email, I didn't realize that you were getting that message as an error in your email. That means that the cron job is set up correctly, something just isn't running.

    wget (Web GET) is a program that basically serves as a simple web downloader. It makes connections to websites and downloads whatever is at the URL that you pass it. It is installed as a server-wide program that is shared by all users. /bin or /usr/bin are directories on the server where binaries (Unix-speak for executable or program files) are stored.

    There are two things you should try:

    1. First, try logging in to the server with SSH, if you have access, and run the wget command from there to see if you get any errors. It may be that (for whatever reason) you aren't allowed to use wget. If you leave off the options (-q -O /dev/null) and just run

    wget http://...

    then you'll see some information that may be helpful in debugging.

    2. Also, try opening the URL in question in your browser and see if it works correctly when you do this.

    To me it looks as if there is a problem with accessing the wget program. You should have access to this, so if this is the case, contact support. There may be an improper permission setting on it on your server. There is also a program called curl that is similar to wget that would also work for this task, although the options you'd have to pass it are a little different. If you strike out with wget then you can try curl. You can find out more about curl at http://curl.haxx.se.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  7. #7
    JPC Member
    Join Date
    Oct 2004
    Posts
    10

    Solved! error in cron job

    Quote Originally Posted by jason
    I misread your first email, I didn't realize that you were getting that message as an error in your email. That means that the cron job is set up correctly, something just isn't running.

    [SNIP]

    There may be an improper permission setting on it on your server.

    --Jason
    You are right, Jason.

    It was an improper permission on the php file.
    Looks like the Moodle installer do not set the permission
    properly for this php file. It was 644 and to function properly
    it has to be set to 645.

    But there is more:

    In the configuration page for cron job in cpanel,
    i noticed this info in red small letters:

    Hint: to run PHP files, enter the command as follows (modify to fit your needs):
    GET http://yourdomain.com/path_to_file/file.php > /dev/null

    Hint: to run CGI files, enter the command as follows (modify to fit your needs):
    GET http://yourdomain.com/cgi-bin/path_to_file/file.cgi > /dev/null

    So, i changed the php line cron to look like this php line and now
    everything is working fine!

    Thanks for a lot the hints!

    alejandro

  8. #8
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    The -O /dev/null that was in your original call should do the same thing as the > /dev/null, but regardless, I'm glad that you got it working.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •