Koozali.org: home of the SME Server

Obsolete Releases => SME Server 7.x => Topic started by: utti on March 21, 2007, 08:36:36 AM

Title: cron php problem ....
Post by: utti on March 21, 2007, 08:36:36 AM
Hi everybody !

I have problem with running php script in cron. I've searched and read everything about my problem ... and nothing helps. My problem began in January 17. after sme-update/upgrade ...

Running that script is very important because my cms-systems e-mail notify does not work anymore :-(


I've tested:

  */10 * * * * root /usr/bin/php http://test.testbox.test/cron.php > /dev/null

  */10 * * * * /usr/bin/php http://test.testbox.test/cron.php > /dev/null

  */10 * * * * lynx -dump -accept_all_cookies http://test.testbox.test/cron.php > /dev/null

  */10 * * * * root lynx -dump -accept_all_cookies http://test.testbox.test/cron.php > /dev/null
   
  */10 * * * * wget -q -O /dev/null http://test.testbox.test/cron.php

and NONE of those works !!!!

When I run php script manual from webbrowser ... EVERYTHING works !!

My Apache uses php from module ... (I think so ).

So ... can anybody tell what's going wrong with cron ???


....lasse....
Title: Re: cron php problem ....
Post by: cactus on March 21, 2007, 09:36:42 AM
Quote from: "utti"
Hi everybody !

I have problem with running php script in cron. I've searched and read everything about my problem ... and nothing helps. My problem began in January 17. after sme-update/upgrade ...

Running that script is very important because my cms-systems e-mail notify does not work anymore :-(


I've tested:

  */10 * * * * root /usr/bin/php http://test.testbox.test/cron.php > /dev/null

  */10 * * * * /usr/bin/php http://test.testbox.test/cron.php > /dev/null

  */10 * * * * lynx -dump -accept_all_cookies http://test.testbox.test/cron.php > /dev/null

  */10 * * * * root lynx -dump -accept_all_cookies http://test.testbox.test/cron.php > /dev/null
   
  */10 * * * * wget -q -O /dev/null http://test.testbox.test/cron.php

and NONE of those works !!!!

When I run php script manual from webbrowser ... EVERYTHING works !!

My Apache uses php from module ... (I think so ).

So ... can anybody tell what's going wrong with cron ???


....lasse....
Remove the > /dev/null part and you should get a mail message to the admin which displays output of error messages for instance. It might have to do with cron not all jobs seem to be ran as as root, what are the rights and ownerships of the files?
Title: cron php problem ....
Post by: utti on March 21, 2007, 10:06:19 AM
Ok.  /dev/null removed !!

MY cms is working normal www user ... in /ibays/Primary/html
I've allready changed cron.php attributes so that everybody can run it.

Let's look whats inside admin posts....

...lasse...
Title: cron php problem ....
Post by: Curly on March 21, 2007, 08:33:06 PM
If http://test.testbox.test/cron.php is your server, then you simply execute the script like

Code: [Select]
*/10 * * * * /usr/bin/php -f  /home/e-smith/files/primary/html/cron.php

Leave the redirect away and you should get an mail containing the error messages.
Title: Now cron is mailing ok! ... just /dev/null does not !!!!
Post by: utti on June 18, 2007, 05:30:07 PM
Mail is going out .. thanks Curly !!!

My problem is now:

1)  I changed in crontab */10 * * * * to 0,30 * * * * and same line in templates 10runparts. I reconfigured systen from server-manager and booted system..... Cron do her job still every 10 minutes !!!!

2) php script output that I sent do >/dev/null sends email to admin ... not good :-(

It looks like from somewhere old settings controls system and the new ones does not !! Are there somekind database about systemsettings and now I can't update it.... How I do it ???

..lasse..
Title: cron php problem ....
Post by: Curly on June 18, 2007, 08:25:10 PM
After changing something in the templates, you should expand the template.

Code: [Select]
/sbin/e-smith/expand-template /etc/crontab

Then you will probably have to stop / start cron.

Code: [Select]
service crond restart

Otherwise cron will still be running your old script.

If the > /dev/null doesn't catch all output, just add 2>&1 at the end:

Code: [Select]
*/10 * * * * /usr/bin/php -f  /home/e-smith/files/primary/html/cron.php >/dev/null 2>&1

The >/dev/null takes care of the standard output, the 2>&1 takes care of the errrors.
Title: cron php problem ....
Post by: utti on June 19, 2007, 12:48:00 PM
This is very intresting ...

When I make:
  /sbin/e-smith/expand-template /etc/crontab
every changes that I've done in 10runparts is coming in crontab ...
but when I make:
  service crond restart
to restart crond ... nothing changes !!! Somewhere hides old values !!!! And I cant make any changes to cron !!!!

How I refresh those values .... Halting system, rebooting system does not work ?? SME-server should not be THAT secure :-)


..lasse..
Title: cron php problem ....
Post by: cactus on July 06, 2007, 05:26:00 PM
Quote from: "Curly"
Code: [Select]
*/10 * * * * /usr/bin/php -f  /home/e-smith/files/primary/html/cron.php
To me it seems that you let the user as which to run the job is missing, is this not required?

Perhaps the /var/log/messages file displays some error messages about this?

If I look in my /etc/crontab I find instructions like this:

Quote
Code: [Select]
12 1 */7 * * root       /sbin/e-smith/signal-event logrotate


I suspect that it should tun every 10 minutes when you change it to:
Code: [Select]
*/10 * * * * root /usr/bin/php -f  /home/e-smith/files/primary/html/cron.php
(you might have to restart cron, but I am not sure about that.
Title: cron php problem ....
Post by: CharlieBrady on July 06, 2007, 07:45:35 PM
Quote from: "Curly"

Code: [Select]
*/10 * * * * /usr/bin/php -f  /home/e-smith/files/primary/html/cron.php >/dev/null 2>&1

The >/dev/null takes care of the standard output, the 2>&1 takes care of the errrors.


And you should (almost) never redirect errors to /dev/null. OP is confused because he doesn't know what is going wrong. It's bad advice to suggest that the informative error messages should be thrown away without anyone having an opportunity to read them.