LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cronjob not working.. (http://www.linuxquestions.org/questions/linux-newbie-8/cronjob-not-working-747087/)

vivendi 08-12-2009 03:30 PM

cronjob not working..
 
Hello, i tried to add a cronjob, but for some reason it isn't working...

I want the cronjob to be executed every minute. So i added this line to my crontab:

* * * * * /usr/bin/php /var/www/em/test.php

I also tried to run the test.php file from the terminal manually. And the php file executed correctly. So there's no error in the php file.

<?php
mysql_connect("localhost", "****", "****");
mysql_select_db("testdb01") or die(mysql_error());

$insert = "INSERT INTO test (msg) VALUES ('blaat')";
mysql_query ( $insert ) or die ( mysql_error() );
?>

But the cron still isn't working... Anyone any idea what the problem might be..???

anomie 08-12-2009 03:40 PM

Check mail(1) for the user the cronjob is running as. By default, stdout/stderr from your cronjobs goes there.

vivendi 08-12-2009 03:50 PM

Quote:

Originally Posted by anomie (Post 3640966)
Check mail(1) for the user the cronjob is running as. By default, stdout/stderr from your cronjobs goes there.

I'm sorry, i really new to Linux so i'm not sure what you mean by mail(1)...
I didn't specify any email anywhere for the cronjob, if that's what you need to know.

Tinkster 08-12-2009 03:57 PM

Depending on your distro there's most likely a mail-server set-up
for local delivery of mail. If you have mail, mailx, nail, mutt,
pine, ... installed you should be able to read notifications from
cron regarding the output of your script.

Also check the relevant log-files under /var/log (again, it all
depends on your distro ;} ... may want to add that to your profile!
Hint, hint.)

grep -i cron /var/log/* for a first glimpse.


Cheers,
Tink

vivendi 08-12-2009 04:18 PM

I don't have any mail server running, so i dont receive any mails with errors.

I checked the logs with the cmd you gave and this is what i got (its not eveything but i think its enough info):

http://pastebin.com/me8ccbdd

It doesn't mean much to me, but maybe you can see any errors or something...

Oh, and i'm running the latest kubuntu (9.04).

Tinkster 08-12-2009 04:29 PM

Ok ... so *buntu have disabled local mail delivery; great :D

In that case, make it something like
Code:

* * * * * /usr/bin/php /var/www/em/test.php >> /tmp/cron_out 2>&1

vivendi 08-12-2009 04:40 PM

Quote:

Originally Posted by Tinkster (Post 3641029)
Ok ... so *buntu have disabled local mail delivery; great :D

In that case, make it something like
Code:

* * * * * /usr/bin/php /var/www/em/test.php >> /tmp/cron_out 2>&1

I feel like such an ass... :redface: I checked the cron_out file and it said it couldn't find the file /var/www/test.php

I had the path wrong all the time cause it should've point to /var/www/em/test.php

But it works perfectly now :)

Thanks alot for you help!!


All times are GMT -5. The time now is 12:29 PM.