#!/usr/bin/env php array('file','/dev/null','r'), 1=>array('pipe','w'), 2=>array('pipe','w'), ); $process = @proc_open($command, $spec, $pipes, null, $env); $stdout = ''; $stderr = ''; $exit = 1; if (is_resource($process)) { $stdout = (string)stream_get_contents($pipes[1]); $stderr = (string)stream_get_contents($pipes[2]); fclose($pipes[1]); fclose($pipes[2]); $exit = proc_close($process); } else { $stderr = 'run-all.sh konnte nicht gestartet werden.'; } $state = native_scheduler_state($stateFile); $state['enabled'] = true; $state['mode'] = 'piwigo-native'; $state['state'] = $exit === 0 ? 'success' : 'error'; $state['message'] = $exit === 0 ? 'NC-Abgleich erfolgreich abgeschlossen.' : 'NC-Abgleich fehlgeschlagen.'; $state['timestamp'] = time(); $state['finished_at'] = time(); $state['exit_code'] = $exit; $state['stdout'] = trim($stdout); $state['stderr'] = trim($stderr); if (empty($state['next_due']) || (int)$state['next_due'] < time()) { $state['next_due'] = time() + 60; } native_scheduler_write($stateFile, $state); @flock($lock, LOCK_UN); fclose($lock); exit($exit === 0 ? 0 : 1);