Create a CRON job from PHP
Good time of day.
My question is, is it really possible to create a job for CRON directly from PHP? That is, I want that when executing a script, a task is set that will be executed in 3 days.
I still have one option - to put a CRON on every day, which will check for new tasks and, if they are found, perform them. But these are unnecessary CRON jobs, in fact. And I would like to create only the necessary tasks, but at the same time so that they are created by the script itself.
1 answers
Working directly with the crown via PCP is not recommended (and I do not even know if it is possible).
The best option, in my opinion, is to do as follows:
1) Create a database and a table that will store your tasks (if necessary, then another table or file that will contain the execution log).
2) Write a pcp script that will check this table and execute scripts whose time has come, but the execution marks have not yet been completed worth.
3) Add a task in the crown to run this script, for example, every hour (yes, at least every 10 minutes or a minute).
In this case, you will have all the opportunities for full-fledged work and setting a schedule.
In theory, there is still missing point 4 - to make an API for working with your system (adding/changing / deleting tasks, getting a list of tasks, etc.).
P.S. Here found material on working with the crown directly with pcp. There are still various ways through which you can directly change the /etc/crontab file , but IMHO it is a bad style to give access to the pcp user to work directly with the crown.