Your crontal -l command only displays what is planned for your user in your personal crontab. It may return an empty string, depending on your current personal crontab. Do not mix with the / etc / crontab file, which is a system-wide crontab, for all root-only users.
If you need - as it seems to me, I understand - add work to crontab from a php script, you might just want to try something like:
$r=shell_exec('cat "30 6 * * * user my_cmd my_args" >> /etc/crontab');
To schedule "my_cmd my_args", for example, "user", 6:30 in the morning every day. This PHP script should be run as root, since only it can write in / etc / crontab.
Caution: I hope that your php script does not start from the website, but from the command line from the restricted environment to limit security risks, especially if you do something to start from the root. This kind of script is a very big hole in your system. Think about it. That is my advice.
By the way, / usr / bin / crontab allows:
-rwxr-sr-x 1 root crontab 35040 19 déc. 2010 / usr / bin / crontab (example from the Debian system).
michauko
source share