I'm trying to delete specific cron job with my PHP script. First of all I'm trying to get current cron jobs using shell_exec:
shell_exec('crontab -l');
When this script executing from webbrowser shell_exec returns all current cron jobs. But when this script executing from cron job shell_exec returns empty string. Why?
On another webhosting this works fine, but here I have this issue. I tried to find the reason or solution, tried different ways but didn't found any working solution.
You must put the entire path of the command, in this case, the path of crontab
. Because when the crontab executes their jobs, there is no environment variable $PATH to look for binaries