Results 1 to 10 of 15
Hello,
I've got several cron jobs setup in crontab, however none of them run as far as i can see. I've been working with the hosts of my dedicated server, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-14-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 13
Cron just not working?
Hello,
I've got several cron jobs setup in crontab, however none of them run as far as i can see. I've been working with the hosts of my dedicated server, but there proving less than useful in solving the problem.
My question is this: is there a cron job that i can setup, which will do something on the server, or email me etc without the need for external files?
(all of my cron jobs are to run php files, which my host belives all have errors.)
So i would like to be able to see if cron is actually working. (also is there a way to view cron's log? if it has one, to see if there are errors?)
my crontab looks like this:
MAILTO=myemail@mydomain.com
*/15 * * * * /usr/bin/php -q /home/a/c/acornmedia/public_html/tools/pingclient/cron.php > /dev/null
08 * * * * /usr/bin/php -q /home/a/c/acornmedia/public_html/cron.php > /dev/null
(removed my email address)
Or can anyone see a problem with my cron jobs?
I hope someone can help, this has been going on for far too long!
- 07-14-2008 #2Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
Hi copes,
cron will log activity to /var/log/cron
You could also add an entry that will simply
echo "something" > to_a_file_of_your_choice
To see if it's working....RHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.
- 07-14-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 13
i've setup a cronjob to run:
*/05 * * * * echo "testing cron" > /home/a/c/acornmedia/public_html/crontest.txt
i also ran the command:
echo "testing cron" > /home/a/c/acornmedia/public_html/crontestmanual.txt
which worked, when i run the commands i want to work without cron, they don't work either.
e.g:
*/15 * * * * /usr/bin/php -q /home/a/c/acornmedia/public_html/cron.php > /dev/null
which doesn't work?
here is the code from the cron.php:
Which when i browse to in my browser, works perfectly. I can only guess that the problem im having is something relating to getting the php to run.PHP Code:<?
$to = 'blankedout@forsecurity.com';
$subject = 'Test Email';
$message = '<b>Test</b>';
$headers = "From: Test <blankedout@forsecurity.com>\n"; $headers .= "X-Sender: <blankedout@forsecurity.com>\n"; $headers .= "Return-Path: <blankedout@forsecurity.com>\n"; $headers .= "X-Mailer: PHP\n"; $headers .= "X-Priority: 5\n"; $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; $headers .=
"MIME-Version: 1.0\n";
mail($to, $subject, $message, $headers);
?>
when i try just running /home/a/c/acornmedia/public_html/cron.php i get a whole list of errors in the console.
- 07-14-2008 #4Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
What sort of messages are you getting ?
RHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.
- 07-14-2008 #5Just Joined!
- Join Date
- Jun 2008
- Posts
- 13
root@ds4637:~# /home/a/c/acornmedia/public_html/cron.php
/home/a/c/acornmedia/public_html/cron.php: line 1: ?: No such file or directory
/home/a/c/acornmedia/public_html/cron.php: line 3: =: command not found
/home/a/c/acornmedia/public_html/cron.php: line 4: =: command not found
/home/a/c/acornmedia/public_html/cron.php: line 5: =: command not found
/home/a/c/acornmedia/public_html/cron.php: line 7: =: command not found
/home/a/c/acornmedia/public_html/cron.php: line 7: .=: command not found
/home/a/c/acornmedia/public_html/cron.php: line 7: .=: command not found
/home/a/c/acornmedia/public_html/cron.php: line 7: .=: command not found
/home/a/c/acornmedia/public_html/cron.php: line 7: .=: command not found
/home/a/c/acornmedia/public_html/cron.php: line 7: .=: command not found
/home/a/c/acornmedia/public_html/cron.php: line 7: .=: command not found
/home/a/c/acornmedia/public_html/cron.php: line 8: MIME-Version: 1.0\n: command not found
/home/a/c/acornmedia/public_html/cron.php: line 10: syntax error near unexpected token `$to,'
/home/a/c/acornmedia/public_html/cron.php: line 10: `mail($to, $subject, $message, $headers);'
- 07-14-2008 #6Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
You need to tell it it's php I haven't used command line php for a while but I think the standard #! will work i.e.
#!/usr/bin/php
at the beginning of your .php filesRHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.
- 07-14-2008 #7Just Joined!
- Join Date
- Jun 2008
- Posts
- 13
In the actual php files themselves?
- 07-14-2008 #8Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
Yes then you can just call the script, otherwise they should work if you call it through php
#/usr/bin/php my_script.phpRHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.
- 07-14-2008 #9Just Joined!
- Join Date
- Jun 2008
- Posts
- 13
Hello,
I've added:
#!/usr/bin/php
as the first line in the cron.php
and now when i run:
/home/a/c/acornmedia/public_html/cron.php
in the command line, i don't get any errors. however i don't receive any mail from the script either. Could there be something else wrong?
- 07-14-2008 #10Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
Do you have access to /var/log ?
RHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.


Reply With Quote
