LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 08-12-2009, 04:30 PM   #1
vivendi
LQ Newbie
 
Registered: Jan 2006
Posts: 20

Rep: Reputation: 0
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..???
 
Old 08-12-2009, 04:40 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
Check mail(1) for the user the cronjob is running as. By default, stdout/stderr from your cronjobs goes there.
 
Old 08-12-2009, 04:50 PM   #3
vivendi
LQ Newbie
 
Registered: Jan 2006
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by anomie View Post
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.
 
Old 08-12-2009, 04:57 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,999
Blog Entries: 11

Rep: Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881
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
 
Old 08-12-2009, 05:18 PM   #5
vivendi
LQ Newbie
 
Registered: Jan 2006
Posts: 20

Original Poster
Rep: Reputation: 0
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).
 
Old 08-12-2009, 05:29 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,999
Blog Entries: 11

Rep: Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881
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
 
Old 08-12-2009, 05:40 PM   #7
vivendi
LQ Newbie
 
Registered: Jan 2006
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Tinkster View Post
Ok ... so *buntu have disabled local mail delivery; great

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... 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!!
 
  


Reply

Tags
cron, cronjob, crontab, executing, file, job, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cronjob not working vinaytp Linux - Newbie 3 06-23-2009 10:06 AM
Cronjob stops working after a while ToonM Slackware 4 01-23-2007 01:53 AM
Cronjob not working, stops at lynx prompt abefroman Linux - Server 3 11-01-2006 02:58 PM
Call of Duty 2 Cronjob Not working zend Linux - Software 3 11-15-2005 11:52 AM
cronjob not working but script works dtra Linux - Newbie 4 02-28-2005 06:05 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration