For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > March 2005 > Re: [PHP-DB] Command Line Error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Command Line Error
Martin Norland

2005-03-28, 3:56 pm

Ron Piggott wrote:
> I wrote a really simple 11 or 12 line PHP script to remove old entries from
> a web card application I made:
>
> <?
>
> $todays_date=DATE("Y-m-d");

[snip]
> Take a look at this line:
>
> $todays_date=DATE("Y-m-d");
>
> When it is ran from the command line this line causes the script to give
> these error messages:
>
> /home/actsmin/actsministries-www/webcards/administration/daily_maintenance.p
> hp3: line 3: syntax error near unexpected token `DATE("'
> /home/actsmin/actsministries-www/webcards/administration/daily_maintenance.p
> hp3: line 3: `$todays_date = DATE("Y-m-d");'
>
> Any idea why the command line can't deal with but the http:// version works
> just fine?


I'm guessing you're not running this through php, you've just made it
executable? You need to either give it some #! magic (e.g. #!/bin/php)
- or - more clearly, call php from cron and pass it this script. (In
either case, <?php is better form than just <?.

00 8-19/2 * * mon-fri /usr/bin/php /foo/backup_script.php

[if you aren't suppressing output properly, you can also do this]

00 8-19/2 * * mon-fri /usr/bin/php /foo/backup_script.php > /dev/null

[though it's better to suppress output properly, so you can get any
error messages/etc.]


cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.
Martin Norland

2005-03-28, 3:56 pm

Martin Norland wrote:
> 00 8-19/2 * * mon-fri /usr/bin/php /foo/backup_script.php


I should have mentioned this - this runs twice an hour Monday through
Friday, between the hours of 8am and 7pm. You would more likely prefer

05 1 * * * your_command

which would run at 1:05am every day. use 'crontab -e' to edit your own
crontab.

cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com