Can we configure cron job's time interval through PHP script, so that the time interval should not be set manually, but through a PHP script, whether it takes time interval from Database or fixed (but from within the PHP code).
Thanks in advance
Timing – set the weekday, months, days, hours and minutes. Execute – the cron job needs to be called in PHP to run – that's located at /usr/bin/php path. Script Path – the path of the file you want to run. Output – you are allowed to add the cron output to a file or discard it. /dev/null 2>&1 will discard.
Every minute: if you want to run a cronjob every minute then you would use the wild card symbol * . If however you wanted to run it every x minutes you would use */x for example every 5 minutes would be */5 or for every 15 minutes */15 . The next option is to specify the minutes separated by , for example 3,16,23,48 .
I think it is much better to let your application control the frequency of events instead of the cronjob. Let the cronjob run a certain action of your application every minute. The action then for example checks a database table named cronjobs and runs the jobs marked for running by either a frequency number or a timestamp.
If you do it like this, you can add new jobs programmatically from everywhere, e.g. via an cronjob interface. The solution is easier to maintain, to test and to document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With