+ Reply to Thread
Results 1 to 7 of 7

Thread: Cronjobs and the log

  1. #1
    OdieusG is offline x10Hosting Member OdieusG is an unknown quantity at this point
    Join Date
    Jan 2009
    Location
    Bangor, Maine
    Posts
    50

    Question Cronjobs and the log

    I'm curious.....is there a way to report an error code in the cronjobs? I recieve the job log, but it's all a list of entries of 0s....which means, I assume, that the script has completed successfully.....should I use the exit function with a code or something?

  2. #2
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Cronjobs and the log

    Why not have the cron job create a text file with some output?

    Zero error code just means that no errors (syntax, function call to function not defined, etc) happened. A function returning false and failing to meet its purpose is still error code 0.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  3. #3
    OdieusG is offline x10Hosting Member OdieusG is an unknown quantity at this point
    Join Date
    Jan 2009
    Location
    Bangor, Maine
    Posts
    50

    Re: Cronjobs and the log

    Quote Originally Posted by garrettroyce View Post
    Why not have the cron job create a text file with some output?

    Zero error code just means that no errors (syntax, function call to function not defined, etc) happened. A function returning false and failing to meet its purpose is still error code 0.
    The script is currently working in the MySQL database, and it's all for a standard security measure.....so no one tries to advance "the clock" for their benefit.....more for just noting if particular things happen.....

    This is the per-minute log it reports.....even though I'd prefer it just append to a log or something, but would fill space immensely....
    Code:
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    
      0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
      0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
    Currently I have it typechecking for a particular code for it to run, using the GET method, so I just want it to report a code if that code is invalid or missing......
    Last edited by OdieusG; 05-08-2009 at 10:30 PM.

  4. #4
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Cronjobs and the log

    I'm not really understanding what your script is doing, maybe you can PM me with more details if you don't want to explain it here.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  5. #5
    OdieusG is offline x10Hosting Member OdieusG is an unknown quantity at this point
    Join Date
    Jan 2009
    Location
    Bangor, Maine
    Posts
    50

    Re: Cronjobs and the log

    Quote Originally Posted by garrettroyce View Post
    I'm not really understanding what your script is doing, maybe you can PM me with more details if you don't want to explain it here.
    I basics, instead of the information by default, sent by the cron-log, have it output (not display) an error code, that's specified......currently everything is nested in an IF statement, with $_GET['id'] as the criteria.......He's a section of code to show what I'm trying to implement:
    Code:
    if($_GET['id'] {
     $ret = "Correct Code";
    } else {
    $ret = "Wrong Code";
    }
    Now what I want is the cronjob to have the $ret variable send instead of the statistics.......

  6. #6
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Cronjobs and the log

    Why don't you do something like this:

    Code:
    $fh = fopen('/user/name/cronlogs/'.time(), w);
    if (!$fh)
         die(); // no point in continuing if file isn't created
    fwrite($fh, $_GET['id']);
    This function will create a file named with the current unix timestamp and write the result to the file. You have to replace /user/name/cronlogs with a path you want the logs to be in.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  7. #7
    OdieusG is offline x10Hosting Member OdieusG is an unknown quantity at this point
    Join Date
    Jan 2009
    Location
    Bangor, Maine
    Posts
    50

    Re: Cronjobs and the log

    Quote Originally Posted by garrettroyce View Post
    Why don't you do something like this:

    Code:
    $fh = fopen('/user/name/cronlogs/'.time(), w);
    if (!$fh)
         die(); // no point in continuing if file isn't created
    fwrite($fh, $_GET['id']);
    This function will create a file named with the current unix timestamp and write the result to the file. You have to replace /user/name/cronlogs with a path you want the logs to be in.
    I was just trying to figure how to replace the cronlogs mail with messages....it's more of a double duty-since the "cronlog stat mail" sends rather ambiguous info, for a script that's about 100 lines of code, and processes in a matter of milliseconds....and only would be unsuccessful of someone tried to use a different authorisation code to increment the information it processes

    Now quite sure if you can understand what I just wrote....I've been up for 1 hour, and only 1 cup of coffee so far
    Last edited by OdieusG; 05-10-2009 at 07:15 AM.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers