I'm working with some scripts which must be executed from crontab. Some of them rewrite crontab.
in.php defines if read.php should be run by crontab. Then read.php is executed by crontab. This works fine.
When read.php is executed, it might detect that it should be not running, if this happens, it rewrites crontab to avoid its own execution, until in.php rewrites crontab again. The problem is that this second step is not working.
I have been looking for the error and I have found that my cron.txt is correctly written. However, crontab command fails and returns 127 error. But when I execute read.php manually all works fine.
Both scripts use the same functions to rewrite crontab. But this is happening just in read.php, not in in.php.
Is there a time to rewrite crontab since it executes a task? It may explain my problem, because in.php takes longer time to be executed than read.php.
Thank you!
PD: I have checked that the path to cron.txt in crontab command is the same if it is executed automatically and if I execute it manually.
EDIT: When I speak about rewriting crontab I refer rewrite a cron.txt file and to execute crontab [path]/cron.txt