Cron Jobs

DeepakG

Perch
I have been trying to setup a cron job for a while now with no success.

I searched this forum to see if anyone has faced the same problem and tried to use solutions suggested but I think I'm still missing something.

Here's what I need to do: Access http://example.net/cron.php every 1 hour

I scheduled the job as follows in HSphere:

Minute: 59
hour/day/month/week: *
Command: /usr/bin/wget -o /hsphere/local/home/<username>/cron.log http://example.net/cron.php

I masked the username and the website address in above command.

I received the following reply via e-mail:

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

Can anyone tell me what is wrong with my command?

Thanks,
Deepak
 
I'm sure Praveen's answer is the best way but of course its only useful for hitting a site on the same account. I'm using a cron on a Linux account to hit a page on a Windows account where we don't have cron.

This is what I use.

wget -O /dev/null http://www.example.com

The -O to null throws away the output rather than saving a file each time. I think your permissions issue is related to the log (-o). Assuming that you really want to the log, you might have to create it manually and set permissions so that the cron user can write to it. That's just a guess.

I didn't want the email but couldn't avoid it so I sent it to a mailbox which discards incoming messages.

Cheers
Ross
 
Ok, I have 2 cron jobs schedule at different time period using both solutions suggested.

First Job

Command: wget -O /dev/null http://dipak.org/cron.php

Result:

Received an e-mail with following message:

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

Second Job

Command: /hsphere/shared/php5/bin/php-cli /hsphere/local/home/<username>/<domain>/cron.php

Result: I did not receive an e-mail with error message. At the same neither job actually worked. I can tell that by looking at the time on my website when the last time cron.php was accessed.

Can someone point out what I am doing wrong?

Deepak
 

Attachments

  • hsphere_cron.jpg
    hsphere_cron.jpg
    34.9 KB · Views: 204
Ok, I finally got the cron jobs working.

The following command is what did the job: /hsphere/shared/php5/bin/php-cli <file_path>

I just had to tweak the path of the file. I was initially using it as follow:

/hsphere/shared/php5/bin/php-cli /hsphere/local/home/<username>/<domain>/cron.php

This threw an error because cron.php included some files using the statement "include_once ./includes/database.php". PHP resolved "." to /hsphere/shared/php5/bin/ which of course was not correct.

After scratching my head for a while, I created a file called cron_hsphere.php and put following lines in it:

Code:
<?php

//Simple way to read the contents of a cgi-script.

$file = 'http://mydomain.com/cron.php';

$result = file ($file);

?>

I scheduled the following command:
/hsphere/shared/php5/bin/php-cli /hsphere/local/home/<username>/<domain>/cron_hsphere.php

This did the trick!

Deepak
 
Back
Top