I have an input field that is setting the interval in days to run a script.
I’m looking for a way to set the cronjob command (ie: * * * * *) using a PHP based on the number of days set. Is there a way to do this or does it have to be manually setup?
Something like:
function daysToCronJobInterval($iDays){
// Something here
return $cronJobInterval;
}
Cronjobs cannot be set like that. Each minute the cron deamon looks for which jobs to run based on the pattern (“is this the correct weekday? is this the correct minute?” and so on). You will need to set up a script check to see if the date is correct because cron cannot do that. You can make that check in the manual job or in Bash.