I'm running into some confusion with the cron_remove api function. It appears it wants a "line number" passed in to remove that line from the cron file. So I call fetchcron to get the list and the list returns 3 items, even though I only have two crons showing cpanel. The first is actually a "MAILTO" entry that is empty.
If I loop over the array of returned items and save off the "line" element for the one that has the command I want to delete, in my case it's the third line and its "line" element is indeed "3". If I then call remove_cron with line=3, it fails and says the cron job doesn't exist.
I've noticed the returned data from fetchcron also has a "commandnumber" element for each line -- except for the MAILTO entry which does not have a commandnumber element. My two valid cron entries have a commandnumer of 1 and 2; there is no #3 since the MAILTO entry doesn't have a commandnumber element. Finding the commandnumber for the entry I want to delete and passing that value (2 in my case) to remove_cron seems to work properly, but I don't know if that's the way I'm supposed to call it to delete the proper line.
The docs page for remove_cron that I found says its deprecated, but I was unable to find any other documentation for a newer remove_cron function through searching.
PS: It would seem to make sense to also let remove_cron take the linekey element from an entry, since it's unique for each entry and doesn't require fetchcron combined with looping just to delete a single entry.
Thanks for any clarification you can provide.
If I loop over the array of returned items and save off the "line" element for the one that has the command I want to delete, in my case it's the third line and its "line" element is indeed "3". If I then call remove_cron with line=3, it fails and says the cron job doesn't exist.
I've noticed the returned data from fetchcron also has a "commandnumber" element for each line -- except for the MAILTO entry which does not have a commandnumber element. My two valid cron entries have a commandnumer of 1 and 2; there is no #3 since the MAILTO entry doesn't have a commandnumber element. Finding the commandnumber for the entry I want to delete and passing that value (2 in my case) to remove_cron seems to work properly, but I don't know if that's the way I'm supposed to call it to delete the proper line.
The docs page for remove_cron that I found says its deprecated, but I was unable to find any other documentation for a newer remove_cron function through searching.
PS: It would seem to make sense to also let remove_cron take the linekey element from an entry, since it's unique for each entry and doesn't require fetchcron combined with looping just to delete a single entry.
Thanks for any clarification you can provide.
Last edited by a moderator: