cron jobs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tiger0
Forum Newbie
Posts: 16
Joined: Mon Oct 28, 2013 12:19 am

cron jobs

Post by tiger0 »

Hello guys. I am new here :D

I have some problems with the cron jobs. I used these two lines in my (cron.txt) file:

Code: Select all

MAILTO=myemail@gmail.com
1 0 * * * * php -f /home/my_user_name/public_html/cron.php
(note: I got this syntax from the web host)
"php -f /home/user_name/public_html/cron.php"


and in my (cron.php) file:

Code: Select all

<?php
$to= "myemail@gmail.com";
$subject = "Cron Job Status";
$from = "myemail@gmail.com";
$message = "The cron job is working fine."; 
mail($to,$subject,$from, $message); 
?>
and that cron.php file is working fine when I run in via the URL.

but it's not working although the permissions for both files are rwxr-xr-x

I also used the cron jobs function from the web host service, but still did not work..

any suggestion?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cron jobs

Post by Celauran »

You have one too many asterisks in your crontab. It's minute, hour, day, month, day of week.
tiger0
Forum Newbie
Posts: 16
Joined: Mon Oct 28, 2013 12:19 am

Re: cron jobs

Post by tiger0 »

Good point Celauran

Thanks.

I removed the extra asterisk, but still the command does not work
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cron jobs

Post by Celauran »

php-cli is installed? It works when you run it manually from the command line?
tiger0
Forum Newbie
Posts: 16
Joined: Mon Oct 28, 2013 12:19 am

Re: cron jobs

Post by tiger0 »

I did not check it from the command line, but the both files cron.txt and cron.php are on the host server.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cron jobs

Post by Celauran »

cron.txt? Is there some script that's parsing that? It may be as simple as adding this entry to your crontab (crontab -e from the shell)
tiger0
Forum Newbie
Posts: 16
Joined: Mon Oct 28, 2013 12:19 am

Re: cron jobs

Post by tiger0 »

Sorry for the late response Celauran

I could not do it through the shell on the website. I got some free website to do the cronjobs for me,

Thanks for your inof. I really appreciate it.
Post Reply