I have a E-mail schedule runs everyday on php page using cron jobs. The php code workds fine when i run the page using a link.
Now when I run the php script using cron jobs, it also works fine but when I put some query the cron jobs won't understand the link.
for example: http://www.wetube.org/cron.php?id=01001
so now if I try to run this everyday using cron job it's doesn't work.
But if we just erase the query it works fine. Do you guys know any code which makes this link work in cron job?
php” file is placed inside the “htdocs” folder. If you want to run it, open any web browser and enter “localhost/demo. php” and press enter. Your program will run.
The App Engine Cron Service allows you to configure regularly scheduled tasks that operate at defined times or regular intervals. These tasks are commonly known as cron jobs. These cron jobs are automatically triggered by the App Engine Cron Service.
* * * * * is a cron schedule expression wildcard, meaning your cron job should run every minute of every hour of every day of every month, each day of the week.
Cron runs commands as they would be ran via the shell, so running PHP would use local paths.
You need to use a command like:
php /home/USER/public_html/cron.php
Or if including the query string is necessary, use cURL instead (if it's installed):
curl http://www.wetube.org/cron.php?id=01001
You might want to look at not exposing your cron scripts to the internet - move them to outside your web directory because if someone finds it they can constantly reload it to spam your cron scripts (i.e. sending lots of emails)
I would add hash like
curl http://www.wetube.org/cron.php?id=01001&hash=cm349ucKuc023b2ynGyv23ycr23
and in php file
if(isset($_GET['hash']) && $_GET['hash']=='cm349ucKuc023b2ynGyv23ycr23'){
....
stuff to do
....
}
*you can even add specific time/date check when it should be run.
*you can check IP
*generate sha512 (I would recommend) hashes in both cron and php file with the same salt and maybe even time and then check if they are the same - it would be impossible for a hacker to recreate it - except if he somehow gets your original hash setup
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