problems with cronjobs.

taturossi

Verified User
Joined
May 14, 2009
Messages
9
Location
Argentina
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' [email protected]

or

1**** [email protected] ; /usr/local/bin/php /domains/site.com/public_html/tests/script.php
 
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?
 
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.
 
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, "[email protected] ; /usr/local/bin/php ..." won't work. It's either "export [email protected] ; /usr/local/bin/php ..." or "[email protected] /usr/local/bin/php ...".
Any environment variable is set only for the current process unless exported:
Code:
$ VAR=bla
$ echo $VAR
bla
$ bash -c 'echo $VAR'

$ export VAR
$ bash -c 'echo $VAR'
bla
 
Last edited:
ok,
now I'm using
/usr/local/bin/php /domains/mysite.com/public_html/tests/testfile.php | mail -s 'file' [email protected]

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
 
Just read my post...
Try with this:
Code:
/usr/local/bin/php ~/domains/mysite.com/public_html/tests/testfile.php 2>&1 |mail -s 'file' [email protected]
I just added "~" to pick the correct path and "2>&1" to channel any error in the Email message.
 
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.
 
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.
 
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
 
Back
Top