wtshing wrote: ↑
Mon Apr 09, 2018 8:39 pm
I create a table to store cron data in mysql, is it possible to set a cron to check the change of the table?
As I want to use a cron to update another cron file so that it can modify and run the scheduled tasks based on the records inside the table.
I haven't got my RPI at hand, you can generate the cron tab file and then overwrite it where it is normally stored using "sudo cp .... "
Theoretically you can do, but it's not an elegant way of doing it. Cron files are stored in /var/spool/cron/crontabs (each Linux user will have his own file) on Debian. They are text files, however you should use "crontab" to amend it, not VI or CP.
Normally you can list your cronjobs:
crontab -l > cron.file.txt
Edit it and then you do :
crontab < cron.file.txt
So you would have to run a script executed from another cron job that would do the latter.
If you have the job details stored in your database somehow (you didn't give the structure here...) then you can just build an SQL to generate the cron.file.txt. You also have to bare in mind you can have only one crontab file per user/ UNIX account. To run a cron job that overwrites itself, could corrupt the cron file.