I have a function which writes into the crontab using PHP script:
function changejob() {
global $existingJobs;
global $newJob;
chmod("/tmp/crontab", 0764);
if (file_put_contents('/tmp/crontab', $newJob.PHP_EOL)) {
if (exec('crontab /tmp/crontab')) {
echo 'Crontab changed to ' .$newJob;
}
else {
echo 'Error with exec command';
}
}
else {
echo 'file_put_input function failed';
}
}
The script echoes 'Error with exec command'. If I immediately then run crontab /tmp/crontab in the command line, the crontab file is edited correctly. So I know the file_put_contents function worked and the echo exec() function did not.
Error reporting is enabled, but nothing was reported.