View Full Version : problems with cronjobs.
taturossi
05-14-2009, 09:51 AM
Hello everyone, I'm trying to run a cronjob but I'm having problems, basically the cronjob is never executed.
This is how I have it configure, but i don't know what is the problem.
1**** /usr/local/bin/php /domains/site.com/public_html/tests/script.php
can anybody help me, because I tried a lot of things but nothing sims to work.
Regards,
taturossi
check the cron logs.
also u cah pipe the output to mail.
1**** /usr/local/bin/php /domains/site.com/public_html/tests/script.php | mail -s 'script' your@email.com
or
1**** MAILTO=your@email.com ; /usr/local/bin/php /domains/site.com/public_html/tests/script.php
taturossi
05-14-2009, 01:11 PM
I'm not getting any response to my email address...
I'm configuriyng averything acording to what the help says, but still isn't working.
I getting out of ideas :(
any other help?
I doubt cron is running then... what does the logs say?
taturossi
05-14-2009, 02:09 PM
how can I see the logs? because I configure my cronjob as you told me to, but I'm not getting anything in my email.
tillo
05-14-2009, 03:33 PM
First thing: do you have a "/domains" directory? If you are referring to "~/domains" use that, because "/" is the root path. "~" is the home directory path.
Second, "MAILTO=your@email.com ; /usr/local/bin/php ..." won't work. It's either "export MAILTO=your@email.com ; /usr/local/bin/php ..." or "MAILTO=your@email.com /usr/local/bin/php ...".
Any environment variable is set only for the current process unless exported:
$ VAR=bla
$ echo $VAR
bla
$ bash -c 'echo $VAR'
$ export VAR
$ bash -c 'echo $VAR'
bla
taturossi
05-14-2009, 04:48 PM
ok,
now I'm using
/usr/local/bin/php /domains/mysite.com/public_html/tests/testfile.php | mail -s 'file' my@mail.com
I'm receiving an email with no message in it, what can I do, to know if my script is being executed? how can I write some message in the email?
thanks
tillo
05-15-2009, 01:42 AM
Just read my post...
Try with this:
/usr/local/bin/php ~/domains/mysite.com/public_html/tests/testfile.php 2>&1 |mail -s 'file' my@mail.com
I just added "~" to pick the correct path and "2>&1" to channel any error in the Email message.
taturossi
05-15-2009, 09:38 AM
Ok, I already apply what you told me to, but now I'm not receiving any email, it seems like today the cronjobs are now been executed. Because the last email I receive it at 3 AM and from them nothing else happend.
1. Put the fullpath to the php file instead of ~
2. Remove the 2>&1 its useless and not gonna do anything for you.
3. What is your script supposed to be doing? If there is no output it probably is not going to email you.
taturossi
05-16-2009, 08:06 AM
the script it's been executed, but I'm getting the following errors:
Warning: main(../lib/folder1/file1.php): failed to open stream: No such file or directory in /home/blabla/domains/site/public_html/tests/insertar2.php on line 3
Warning: main(../lib/folder1/file1.php): failed to open stream: No such file or directory in /home/blabla/domains/site/public_html/tests/insertar2.php on line 3
Warning: main(): Failed opening '../lib/folder1/file.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/blabla/domains/site/public_html/tests/insertar2.php on line 3
Fatal error: Call to undefined function: method() in /home/blabla/domains/site/public_html/tests/insertar2.php on line 7
and my code is very simple:
<?php
include("../lib/folder1/file1.php");
$sqlInsert = "INSERT INTO `table1` ( `desc` )VALUES ('a');";
$res = Ejecutar_SQL( $sqlInsert);
?>
I think that I'm having problems to include file1 in my code, I tried to write the path in different ways but nothing seems to work.
Thanks.
change the include path so that it is the full path to the file.
taturossi
05-16-2009, 08:27 AM
ok, but, what will happend if file1.php include an other file using a relative path?
will throw an error, and I will have to replace all the relative paths for full paths?
I'll try now what toy told me.
thanks.
That or change your command line to include a change of directory.
Like:
cd /home/username/domains/domain.com/public_html ; rest-here
taturossi
05-16-2009, 08:56 AM
It finally works!!!!
thanks very much everybody!!!!:):):):)
Best regards,
taturossi
Powered by vBulletin™ Version 4.0.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.