SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: php in cronjob

  1. #1
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question php in cronjob

    When I run the php program at the command line, it works great. When I run it as a cron job, I get an email stating a whole bunch of errors that start...

    PHP Notice: Undefined variable:
    PHP Notice: Undefined offset:

    What does this mean?

  2. #2
    SitePoint Member
    Join Date
    May 2003
    Location
    California
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jkh1978
    When I run the php program at the command line, it works great. When I run it as a cron job, I get an email stating a whole bunch of errors that start...

    PHP Notice: Undefined variable:
    PHP Notice: Undefined offset:

    What does this mean?
    What have you entered for the cron job? It should be something like:
    Code:
    php /path/filename.php

  3. #3
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Notice: Undefined variable:
    PHP Notice: Undefined offset:
    Sounds more like a script issue, you could show us the script.

  4. #4
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are running a script with url data, such as, this_script.php?something=this&somethingelse=that, then don't.

    You'll need to run it as an include in another script then run that script as cron.

  5. #5
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The script works great at the command line. But when I run it as a cronjob, I'll receive an email about these warnings. Can I just suppress the errors somehow?

  6. #6
    SitePoint Enthusiast
    Join Date
    Feb 2004
    Location
    Vernon,BC
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you just want to suppress the errors do
    php /path/filename.php >/dev/null 2>/dev/null

    I'd recommend fixing or exporting environment settings though..


Bookmarks

Posting Permissions

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