PHP: Protection public cron jobs
Programmers often forget to protect cron jobs that are executed in public addresses. Especially if you have shared hosting, it is usually difficult to secure run cron tasks.
However, if the cron is on publicly url, can this cron job starts anyone. If this one know which URL address enter into browser.
1. Secret variable
“Emergency measure” to secure calls is to use a secret variables that will never be known. This solution is not very good, but sometimes there is no alternative. Especially on shared hosting.
Simply create a cron job in crontab them to add your own variables: