cron help needed

hebrew878

Verified User
Joined
Jul 3, 2011
Messages
61
Location
India
*/1 * * * * /usr/local/bin/php /home/username/domains/domain.com/public_html/cron.php



i setted this for every 1 minute but not working..plz help what is wrong?
 
Well... there are not enough info...

Why you say doesnt work? If you run that command what should do? What log say?

Regards
 
You should use search function of the forum, and you'll definitely find what you need:

Code:
*/1 * * * * cd /home/username/domains/domain.com/public_html/; /usr/local/bin/php /home/username/domains/domain.com/public_html/cron.php

or

Code:
*/1 * * * * /usr/bin/wget -q -O /dev/null http://domain.com/cron.php > /dev/null 2>&1
 
*/1 * * * * /usr/local/bin/php /home/username/domains/domain.com/public_html/cron.php 2> mail -s 'cronjob' [email protected]

This will email you any errors.
 
tanx

You should use search function of the forum, and you'll definitely find what you need:

Code:
*/1 * * * * cd /home/username/domains/domain.com/public_html/; /usr/local/bin/php /home/username/domains/domain.com/public_html/cron.php

or

Code:
*/1 * * * * /usr/bin/wget -q -O /dev/null http://domain.com/cron.php > /dev/null 2>&1


both working fine but due to timeout cron restarting its job again :(



how to set timeout=0 or tries=1 in cron command?
 
it doesnt work that way...it runs no matter what. Adjust your code then in the php file.
 
how to set timeout=0 or tries=1 in cron command?

You can not do it, you can only follow user scsi's recommendations, or run your script with cron less frequently, e.g.

Code:
*/5 * * * * cd /home/username/domains/domain.com/public_html/; /usr/local/bin/php /home/username/domains/domain.com/public_html/cron.php

once per 5 minutes.
 
Hmmpf. I have the same problem with the cronjobs.

I tried the wget-Method. I tried the Method with php. I also tried the method with mail but nothing worked.

I didn't receive a mail.

My cron.php actually writes a small text into a file in the same directory of php-file.
When I use terminal with lynx or the php-method it writes into the file.

Any advice?
 
does your php display an error if it cant find the file? adjust your code.
 
does your php display an error if it cant find the file? adjust your code.


PHP:
//PHP-File cron.php
ini_set('error_log','testlog.log');
$File = "test.txt";
$fh = fopen($File, 'w') or die("can't open file");
$stringData = "Test\n";
fwrite($fh, $stringData);
fclose($fh);
echo "HEEELLLLOOO WOOOORLD";

The test.txt-File is empty and the log-file, too.

Thanks for response.
 
Back
Top