Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
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.
  1. #1
    Just 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!

  2. #2
    Linux 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.

  3. #3
    Just 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:

    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);

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

    when i try just running /home/a/c/acornmedia/public_html/cron.php i get a whole list of errors in the console.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux 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.

  6. #5
    Just 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);'

  7. #6
    Linux 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 files
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

  8. #7
    Just Joined!
    Join Date
    Jun 2008
    Posts
    13
    In the actual php files themselves?

  9. #8
    Linux 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.php
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

  10. #9
    Just 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?

  11. #10
    Linux 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.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •