Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My cronjob isn't working?

Tags:

php

cron

Maybe a silly question, but I'm trying to get a cronjob to work. Although this could be a question for serverfault I think its also a SO-question.

Anyway: I have set up a cronjob to be executed everey 1 minute of every hour, day (number), day (name) and month. The given command is: /home/easybr01/domains/easybranding.nl/public_html/cronjobs/test.php

Which is nothing more than a file with a simpe php function mail(to, subj, content, hdrs) to test if it works... but the mails never come in.. and they're not in a spam folder eighter..

Does someone know what's wrong?? I figured this should be pretty straight forward...

like image 455
Ben Fransen Avatar asked Nov 11 '10 19:11

Ben Fransen


2 Answers

You should indicate ${PATH_TO_PHP} into the cronjob, like :-

* * * * * ${PATH_TO_PHP} /home/easybr01/domains/easybranding.nl/public_html/cronjobs/test.php

Alternatively, you can make the script executable (ex. mod 744),
and place #!${PATH_TO_PHP} into first line of your PHP script, like :-

#!${PATH_TO_PHP}
<?php
// remanding code
?>
like image 99
ajreal Avatar answered Sep 28 '22 00:09

ajreal


For starters, you need to run the PHP command-line interpreter, not just point to a PHP file. If you're giving a command to cron, it needs the whole command.

like image 36
Andrew Avatar answered Sep 27 '22 23:09

Andrew