Cronjobs and the log

OdieusG

New Member
Messages
50
Reaction score
0
Points
0
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?
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
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.
 

OdieusG

New Member
Messages
50
Reaction score
0
Points
0
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:

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
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.
 

OdieusG

New Member
Messages
50
Reaction score
0
Points
0
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.......
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
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.
 

OdieusG

New Member
Messages
50
Reaction score
0
Points
0
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:
Top