Jump to content

[SOLVED] Cronjob returns syntax error


The14thGOD

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.