Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using CronTab to run php scripts

Tags:

php

cron

I need to send emails hourly and daily. I've tried nearly everything but it appears my crontab just won't work. If I run the scripts via a browser e.g

http://localhost/Maisha/Functions/sendhourlymails.php  

my emails get sent beautifully.(I moved default website localhost to public_html.) I don't know whats wrong. I read some post in stack overflow including the executable path of php helps hence I've put the /usr/bin/php before the actual script to be cronned will work but it does not. Removing /usr/bin/php does not work. Adding php before the actual script isn't working. I have the following entries in my crontab.

# m h  dom mon dow   command
0  *  *   *   *    /usr/bin/php /home/maxwell/public_html/Maisha/Functions/sendhourlymails.php
0  0  *   *   *    /usr/bin/php /home/maxwell/public_html/Maisha/Functions/senddailymails.php
like image 839
MaxI Avatar asked Mar 28 '26 19:03

MaxI


1 Answers

Try to call the script via http with wget like so:

* * * * * wget http://localhost/myscript >/dev/null 2>&1
like image 179
markus Avatar answered Apr 02 '26 19:04

markus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!