in Education by
I have set up a cronjob to run a script daily. This script pulls out a list of Ids from a database, loops through each to get more data from the database and geneates an XML file based on the data retrieved. This seems to have run fine for the first few days, however, the list of Ids is getting bigger and today I have noticed that not all of the XML files have been generated. It seems to be random IDs that have not run. I have manually run the script to generate the XML for some of the missing IDs individually and they ran without any issues. I am not sure how to locate the problem as the cron job is definately running, but not always generating all of the XML files. Any ideas on how I can pin point this problem and quickly find out which files have not been run. I thought perhaps add timestart and timeend fields to the database and enter these values at the start and end of each XML generator being run, this way I could see what had run and what hadn't, but wondered if there was a better way. set_time_limit(0); //connect to database $db = new msSqlConnect('dbconnect'); $select = "SELECT id FROM ProductFeeds WHERE enabled = 'True' "; $run = mssql_query($select); while($row = mssql_fetch_array($run)){ $arg = $row['id']; //echo $arg . '
'; exec("php index.php \"$arg\"", $output); //print_r($output); } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by

My suggestion would be to add some logging to the script. A simple

error_log("Passing ID:".$arg."\n",3,"log.txt");

Can give you some info on whether the ID is being passed. If you find that that is the case, you can introduce logging to index.php to further evaluate the problem.

Btw, can you explain why you are using exec() to run a php script? Why not excute a function in the loop. This could well be the source of the problem.

Because with exec I think the process will run in the background and the loop will continue, so you could really choke you server that way, maybe that's worth trying out as well. (I think this also depends on the way of outputting:

Note: If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

Related questions

0 votes
    I have set up a cronjob to run a script daily. This script pulls out a list of Ids from a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    (I'm using the pyprocessing module in this example, but replacing processing with multiprocessing should probably ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    (I'm using the pyprocessing module in this example, but replacing processing with multiprocessing should probably ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 7, 2022 in Education by JackTerrance
0 votes
    (I'm using the pyprocessing module in this example, but replacing processing with multiprocessing should probably ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 6, 2022 in Education by JackTerrance
0 votes
    Set the cron job, but the order email will auto cc to other customers and I don't know why. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    My local windows webserver (IIS) doesn't log php errors to log file.The php53_errors.log file is always ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 3, 2022 in Education by JackTerrance
0 votes
    Which of them is not a proper step in competitive intelligence data processing? (a) Data gathering (b) Data ... Security questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 2, 2021 in Education by JackTerrance
0 votes
    Which one of the following is a proper step in competitive intelligence data processing? (a) Competitors' data ... questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 2, 2021 in Education by JackTerrance
0 votes
    How do you handle a situation in which unexpected errors occur during the execution of a script?...
asked Oct 19, 2020 in Technology by JackTerrance
0 votes
    I am facing problems in _files which isn't defined if I execute the script with exec, ececfile and in _module_ ... help me with this? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Using which component you can calculate the processing time of one or more Subjobs in the main Job? tFlowMeter tChronometerStart tFlowMeterCatcher tStatCatcher...
asked Mar 25, 2021 in Technology by JackTerrance
0 votes
    In Job processing, what happens in Purge stage? A - Selection of Initiator for execution of Job B - Job statement ... D - Allocated resources and the JES SPOOL space is released...
asked Dec 4, 2020 in Technology by JackTerrance
0 votes
    In Job processing, what happens in Hard copy stage? A - Selection of Initiator for execution of Job B - Job ... D - Allocated resources and the JES SPOOL space is released...
asked Dec 4, 2020 by JackTerrance
0 votes
    In Job processing, what happens in Execution stage? A - Selection of Initiator for execution of Job B - Job ... D - Allocated resources and the JES SPOOL space is released...
asked Dec 4, 2020 in Technology by JackTerrance
...