I want to run a cron job. My application is developed in PHP and Mysql.
In browser if i use $_SERVER[HTTP_HOST]
in coding, it works fine. But if I use the same thing in cron job it is giving errors.
Can any body give suggestion to fix this?
You might discover that your job works when run via the command line, but won't run via cron. This may be due to the location you're executing from or the PATH you're using. The use of relative paths is a common cause of cron issues. In cron, the PATH is set by default to /bin:/usr/bin .
It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .
Running the “systemctl” command along with the status flag will check the status of the Cron service as shown in the image below. If the status is “Active (Running)” then it will be confirmed that crontab is working perfectly well, otherwise not.
Stop a cron job You can stop a single cron job by removing its line from the crontab file. To do that, run the crontab -e command and then delete the line for the specific task. Alternatively, you can stop the cron job by commenting it out in the crontab file.
$_SERVER['HTTP_HOST']
is not populated when running it from a cronjob, the file is not accessed via HTTP.
You will either have to hardcode the Host or pass it via a command line argument and access it via the $_SERVER['argv']
array.
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