Running php files via crontab

software development

#1

I have added this command to my crontab (edited for privacy):
59 * * * * /home/user/domain.domain.com/cache.php

Now what this should do is cache the sizes of all my pages in
domain.domain.com. This is being used to be like mod_bandwidth (I will release source later). However, I got this error:
/home/user/domain.domain.com/cache.php: line 1: ?: No such file or directory
/home/user/domain.domain.com/cache.php: line 2: =: command not found
/home/user/domain.domain.com/cache.php: line 3: =: command not found
/home/user/domain.domain.com/cache.php: line 4: =: command not found
/home/user/domain.domain.com/cache.php: line 5: =: command not found
/home/user/domain.domain.com/cache.php: line 7: syntax error near unexpected token (' /home/user/domain.domain.com/cache.php: line 7:$dateDayConfig = strval(date(d) - 1);’

It seems the server doesn’t think its php… anyone have any idea on how to fix this? I have a custom copy of php installed as well. So all php runs through:
/home/user/domain.domain.com/cgi-bin/php.cgi


Use “DCOUNTME” promo code when registering and recieve up to $85 off! (referer: saygoodbye)


#2

You’ll have to tell cron to use php to run this file, or it simply treats it as standard shell scripting.

So it should look something like
59 * * * * /home/usernme/path/to/php /home.user/domain.com/cache.php

-Matttail