TSP Posted January 22, 2016 Share Posted January 22, 2016 I'm trying to investigate frequent downtime periods that happens fairly daily, but still not with a clear interval between each time. In doing that I'm trying to now look over whether any of the tasks cause this. The problem I have with that is that there are no log entries for when each task has actually been executed, so I can't see if any of the previous execution times for tasks corresponds to the times our servers tend to go down. Link to comment Share on other sites More sharing options...
emilhem Posted January 24, 2016 Share Posted January 24, 2016 I would also like to know how to make tasks more expressive when they are run or not (i.e. logs in task log). Link to comment Share on other sites More sharing options...
TSP Posted January 27, 2016 Author Share Posted January 27, 2016 And you should log how long time the task spent. I've added some custom code to log this myself now in system/Task/Task.php public function runAndLog() { # HW_CUSTOM log task runnings \IPS\Log::i( LOG_NOTICE )->write( "Start to run task {$this->id}($this->key)", 'taskRunLog' ); $start = microtime( true ); $result = NULL; $error = FALSE; try { $result = $this->run(); } catch ( \IPS\Task\Exception $e ) { $result = $e->getMessage(); $error = 1; } $end_time = round( microtime( true ) - $start, 5 ); \IPS\Log::i( LOG_NOTICE )->write( "Task {$this->id}($this->key) was finished in {$end_time} seconds", 'taskRunLog' ); if ( $error !== FALSE or $result !== NULL ) { \IPS\Db::i()->insert( 'core_tasks_log', array( 'task' => $this->id, 'error' => $error, 'log' => json_encode( $result ), 'time' => time() ) ); } } But I feel you should log this information to the database table. Link to comment Share on other sites More sharing options...
SJ77 Posted January 27, 2016 Share Posted January 27, 2016 thank you for sharing Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.