Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm new to CRON and setting up for the first time to send an email that works when I go to the URL, so it is not the PHP file.

I have this in the crontab file:
# m h dom mon dow user	command
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*  *    * * *   /usr/bin/php /var/www/html/tsl/email1.php 


So, as a result, it should execute my file Email1.php which sends me an email every minute (timing to be changed once it works).

Any help is appreciated!

What I have tried:

As a user, I tried to use root, but from research, I should use the above to process the PHP file correctly.
Posted
Updated 16-May-20 17:20pm

1 solution

Well, I take it
/usr/bin/php /var/www/html/tsl/email1.php
works when you run it from a terminal/command-line ? if so, good

Next, are you 'tailing'/checking /var/log/syslog to see if anything useful comes up there ?

I am assuming here you dont have /etc/cron.allow or /etc/cron.deny files that are blocking your user - on a new Ubuntu install, it's unlikely, but worth checking for

btw, I hope you're using 'crontab -e' or 'sudo crontab -e' to edit your file, strange things may happen if not
 
Share this answer
 
v2
Comments
Cody O'Meara 16-May-20 23:51pm    
Thank you for your response. I checked the syslog and everything looked good:
CMD (/usr/bin/php /var/www/html/tsl/email1.php)

Just for the heck of it, I deleted the line in the crontab. I reentered including the root and it is working now. Thank you so much!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900