The14thGOD Posted November 3, 2009 Share Posted November 3, 2009 I have a cron job going and its finding the right file but it's emailing me back with errors. Syntax errors, but if I run it from the browser it runs fine. Error: /var/path/to/domain/httpdocs/csv_db.php: line 1: ?php : No such file or directory /var/path/to/domain/httpdocs/csv_db.php: line 2: syntax error near unexpected token `(' /var/path/to/domain/httpdocs/csv_db.php: line 2: ` $dbh = mysql_connect("localhost","username","password"); CronJob: 52 * * * * /var/path/to/domain/httpdocs/csv_db.php Start of PHP: <?php $dbh = mysql_connect("localhost","username","password"); mysql_select_db("db"); $date = date("Y-m-d H:i:s");?> Any ideas? Thanks in advance, Justin Quote Link to comment https://forums.phpfreaks.com/topic/180185-solved-cronjob-returns-syntax-error/ Share on other sites More sharing options...
taquitosensei Posted November 3, 2009 Share Posted November 3, 2009 try 52 * * * * "php /var/path/to/domain/httpdocs/csv_db.php" not sure if you need the quotes around the whole command or not Quote Link to comment https://forums.phpfreaks.com/topic/180185-solved-cronjob-returns-syntax-error/#findComment-950519 Share on other sites More sharing options...
trq Posted November 3, 2009 Share Posted November 3, 2009 Looks like your missing your shebang and therefor bash is trying to execute php. that won't work. Add this to the top of your script. #!/usr/bin/php Of course, you'll need to change that to the correct path to the php executable. Quote Link to comment https://forums.phpfreaks.com/topic/180185-solved-cronjob-returns-syntax-error/#findComment-950554 Share on other sites More sharing options...
The14thGOD Posted November 3, 2009 Author Share Posted November 3, 2009 nope that didnt work, i got a different error however i found this tutorial: http://www.htmlcenter.com/blog/running-php-scripts-with-cron/ basically if you have Apache handling ur PHP and not CGI, you do: 30 * * * * http://www.example.com/cron.php Quote Link to comment https://forums.phpfreaks.com/topic/180185-solved-cronjob-returns-syntax-error/#findComment-950555 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.