Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Lester Caine
On 20/09/16 06:16, Karl DeSaulniers wrote:
> Was probably a newb question, however, now it is saying that my database user 
> is not allowed access.
> I have a mysql connection inside my script that reads the database to get 
> user email addresses to send a reminder email to.
> 
> Is there supposed to be a call or directive to load mysql in my command line 
> as well?
> Man this is frustrating.

The user name and password you are using from the web scripts SHOULD
work in the script you are using on the cron job. Although mysql does
seem to have a few extra security features that cut in. Are they listed
in the script, or loaded from the environment ... which is of cause
different for the cron jobs ... and why you needed the full path.

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers

> On Sep 20, 2016, at 3:06 AM, Lester Caine  wrote:
> 
> On 20/09/16 06:16, Karl DeSaulniers wrote:
>> Was probably a newb question, however, now it is saying that my database 
>> user is not allowed access.
>> I have a mysql connection inside my script that reads the database to get 
>> user email addresses to send a reminder email to.
>> 
>> Is there supposed to be a call or directive to load mysql in my command line 
>> as well?
>> Man this is frustrating.
> 
> The user name and password you are using from the web scripts SHOULD
> work in the script you are using on the cron job. Although mysql does
> seem to have a few extra security features that cut in. Are they listed
> in the script, or loaded from the environment ... which is of cause
> different for the cron jobs ... and why you needed the full path.
> 
> -- 
> Lester Caine - G8HFL
> -

Hi Lester,
They are listed inside the php file.

The error message I get is:

Access denied for user '(user name removed)'@'%' to database '(database name 
removed)'

Thanks for your response.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
> On Sep 20, 2016, at 12:16 AM, Karl DeSaulniers  wrote:
> 
>> On Sep 19, 2016, at 6:14 AM, Richard 
>>  wrote:
>> 
>> 
>> 
>>> Date: Monday, September 19, 2016 03:26:54 -0500
>>> From: Karl DeSaulniers 
>>> 
>>> I am hoping someone can enlighten me on this issue I am having.
>>> I am trying to set up a cron job to run a php file.
>>> I am getting a strange error though.
>>> 
>>> /home/(protected directory)/auto_reminder.php: line 1: ?php: No
>>> such file or directory /home/(protected
>>> directory)/auto_reminder.php: line 2: =: command not found
>>> /home/(protected directory)/auto_reminder.php: line 3: /*WordPress:
>>> No such file or directory
>>> 
>>> This is lines 1, 2 and 3 from my code.
>>> 
>>> >> $error_log = "";
>>> /*WordPress Optons Table*/
>>> 
>>> Am I correct in thinking that the error is saying that php doesn't
>>> exist? Has anyone ever experienced this? Is this a server related
>>> issue? Any clue on how to fix?
>> 
>> What do you have on the "command-line" part of your crontab entry?
>> Your php script will need to be called as a php cgi or cli. Because
>> of the way things get set up via cron, it's best to include the full
>> path to the php binary on the cron command-line.
>> 
> 
> Hey thanks Richard. That was the problem.
> Sorry, I am new to command line and cron jobs. 
> Was probably a newb question, however, now it is saying that my database user 
> is not allowed access.
> I have a mysql connection inside my script that reads the database to get 
> user email addresses to send a reminder email to.
> 
> Is there supposed to be a call or directive to load mysql in my command line 
> as well?
> Man this is frustrating.
> 
> Much thanks for your input!
> 
> Best,
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
> 

Heh, I just noticed the subject line. Got to love auto-correct!
I feel like a corn job at this point...  (:  /)

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Lester Caine
On 20/09/16 09:19, Karl DeSaulniers wrote:
> The command line I am using is as follows.
> 
> /usr/bin/php5 /home/(directory name removed)/auto_reminder.php

Which runs when entered on YOUR command line, but fails in the cron job?
Something in auto_reminder.php needs replacing with the 'full' text as
it is getting information from the local user settings.

> The time stamps (minute, hour, day, etc) that precede the /usr are loaded by 
> my host. just fyi.

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
> On Sep 20, 2016, at 3:06 AM, Lester Caine  wrote:
> 
> On 20/09/16 06:16, Karl DeSaulniers wrote:
>> Was probably a newb question, however, now it is saying that my database 
>> user is not allowed access.
>> I have a mysql connection inside my script that reads the database to get 
>> user email addresses to send a reminder email to.
>> 
>> Is there supposed to be a call or directive to load mysql in my command line 
>> as well?
>> Man this is frustrating.
> 
> The user name and password you are using from the web scripts SHOULD
> work in the script you are using on the cron job. Although mysql does
> seem to have a few extra security features that cut in. Are they listed
> in the script, or loaded from the environment ... which is of cause
> different for the cron jobs ... and why you needed the full path.
> 
> -- 
> Lester Caine - G8HFL
> -


Pardon my ignorance, but what do you mean full path?
Full path of the host name?

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Cron job anomaly

2016-09-20 Thread Karl DeSaulniers

> On Sep 20, 2016, at 3:20 AM, Lester Caine  wrote:
> 
> On 20/09/16 09:10, Karl DeSaulniers wrote:
>> Hi Lester,
>> They are listed inside the php file.
>> 
>> The error message I get is:
>> 
>> Access denied for user '(user name removed)'@'%' to database '(database name 
>> removed)'
>> 
>> Thanks for your response.
> 
> Need a mysql guy to deal with that ;)
> I have seen it myself when trying to use mysql and it's to do with the
> 'network path' but I'm on firebird which simply uses the
> '(user name removed)'
> 
> -- 
> Lester Caine - G8HFL


G, ok, thanks for the input. (: ))

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Lester Caine
On 20/09/16 09:14, Karl DeSaulniers wrote:
> Pardon my ignorance, but what do you mean full path?
Full path to php application.
Cron jobs run as 'root' and so need and user account settings added
manually if they do not match the 'root' environment.

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
> On Sep 20, 2016, at 3:14 AM, Karl DeSaulniers  wrote:
> 
>> On Sep 20, 2016, at 3:06 AM, Lester Caine  wrote:
>> 
>> On 20/09/16 06:16, Karl DeSaulniers wrote:
>>> Was probably a newb question, however, now it is saying that my database 
>>> user is not allowed access.
>>> I have a mysql connection inside my script that reads the database to get 
>>> user email addresses to send a reminder email to.
>>> 
>>> Is there supposed to be a call or directive to load mysql in my command 
>>> line as well?
>>> Man this is frustrating.
>> 
>> The user name and password you are using from the web scripts SHOULD
>> work in the script you are using on the cron job. Although mysql does
>> seem to have a few extra security features that cut in. Are they listed
>> in the script, or loaded from the environment ... which is of cause
>> different for the cron jobs ... and why you needed the full path.
>> 
>> -- 
>> Lester Caine - G8HFL
>> -
> 
> 
> Pardon my ignorance, but what do you mean full path?
> Full path of the host name?
> 
> Best,
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com



The command line I am using is as follows.

/usr/bin/php5 /home/(directory name removed)/auto_reminder.php

The time stamps (minute, hour, day, etc) that precede the /usr are loaded by my 
host. just fyi.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Cron job anomaly

2016-09-20 Thread Lester Caine
On 20/09/16 09:10, Karl DeSaulniers wrote:
> Hi Lester,
> They are listed inside the php file.
> 
> The error message I get is:
> 
> Access denied for user '(user name removed)'@'%' to database '(database name 
> removed)'
> 
> Thanks for your response.

Need a mysql guy to deal with that ;)
I have seen it myself when trying to use mysql and it's to do with the
'network path' but I'm on firebird which simply uses the
'(user name removed)'

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
> On Sep 20, 2016, at 3:22 AM, Lester Caine  wrote:
> 
> On 20/09/16 09:14, Karl DeSaulniers wrote:
>> Pardon my ignorance, but what do you mean full path?
> Full path to php application.
> Cron jobs run as 'root' and so need and user account settings added
> manually if they do not match the 'root' environment.
> 
> -- 
> Lester Caine - G8HFL
> -


OH, ok, I did read something about root earlier.
I think it was something like:

root /usr/bin/php5 /home/(directory name removed)/auto_reminder.php

But not positive. I will have to research that more.
Thank you.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Richard


> Date: Tuesday, September 20, 2016 03:26:39 -0500
> From: Karl DeSaulniers 
>
>> On Sep 20, 2016, at 3:22 AM, Lester Caine 
>> wrote:
>> 
>> On 20/09/16 09:14, Karl DeSaulniers wrote:
>>> Pardon my ignorance, but what do you mean full path?
>> Full path to php application.
>> Cron jobs run as 'root' and so need and user account settings added
>> manually if they do not match the 'root' environment.
>> 
> 
> OH, ok, I did read something about root earlier.
> I think it was something like:
> 
> root /usr/bin/php5 /home/(directory name removed)/auto_reminder.php
> 
> But not positive. I will have to research that more.
> Thank you.
> 
>

Whether cron jobs run as root or a standard user depends on how they
are set up. If set up under a user -- which is the better approach
for general use -- they will run as that user. Really only
system-type cron jobs (that require root access) should be set up to
run as root.

If you use the command: 

   crontab -e

from a user account, then the crontab is set up as that user. The
first 5 fields/values are time/date related, followed by the command
to be invoked. See: man -s5 crontab  for more details.

In that case, the user that mysql sees is the user that is running
the job. So, if your mysql authentication is set to accept
connections/give access to say the user your web server is running as
(which is how php will show by default), then you will either need to
pass those credentials in your cron job php script or, give the user
that's running the cron job access.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Richard


 Original Message 
> Date: Tuesday, September 20, 2016 12:54:38 -0500
> From: Karl DeSaulniers 
>
> On Sep 20, 2016, at 7:21 AM, Richard
>  wrote:
>> 
>> 
>> 
>>> Date: Tuesday, September 20, 2016 03:26:39 -0500
>>> From: Karl DeSaulniers 
>>> 
 On Sep 20, 2016, at 3:22 AM, Lester Caine 
 wrote:
 
> On 20/09/16 09:14, Karl DeSaulniers wrote:
> Pardon my ignorance, but what do you mean full path?
 Full path to php application.
 Cron jobs run as 'root' and so need and user account settings
 added manually if they do not match the 'root' environment.
 
>>> 
>>> OH, ok, I did read something about root earlier.
>>> I think it was something like:
>>> 
>>> root /usr/bin/php5 /home/(directory name
>>> removed)/auto_reminder.php
>>> 
>>> But not positive. I will have to research that more.
>>> Thank you.
>>> 
>>> 
>> 
>> Whether cron jobs run as root or a standard user depends on how
>> they are set up. If set up under a user -- which is the better
>> approach for general use -- they will run as that user. Really only
>> system-type cron jobs (that require root access) should be set up
>> to run as root.
>> 
>> If you use the command: 
>> 
>>   crontab -e
>> 
>> from a user account, then the crontab is set up as that user. The
>> first 5 fields/values are time/date related, followed by the
>> command to be invoked. See: man -s5 crontab  for more details.
>> 
>> In that case, the user that mysql sees is the user that is running
>> the job. So, if your mysql authentication is set to accept
>> connections/give access to say the user your web server is running
>> as (which is how php will show by default), then you will either
>> need to pass those credentials in your cron job php script or,
>> give the user that's running the cron job access.
>> 
> 
> Again, thank you for the response Richard.
> 
> Would you possibly have a link to how to set that up? I mean the
> actual commands. My trouble is I don't know what commands and how
> to write them. Like including a user, forcing the PHP.ini and
> executing the script. All in one line. That is what I am trying to
> accomplish and not sure how. Need to read up on the proper way to
> do this. 
> 

The php.ini that is used will be based on the php rules for the
path(s) (and order) it searches for that file.

The user that is running the script will be the user that the cron
job is set up under. If you set up a cron job as a standard user you
can't assign it to run as a different user. If the issue is mysql
access, you do that just the way you would in a [web]server parsed
php file.

The script is whatever you put on the crontab line.

The script you reference from the crontab entry can be a shell script
that does some setup, and then calls your php script.  Your php
script can have include files (e.g., for mysql connection setup) just
as you might have in a [web]server parsed php file.





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
On Sep 20, 2016, at 7:21 AM, Richard  
wrote:
> 
> 
> 
>> Date: Tuesday, September 20, 2016 03:26:39 -0500
>> From: Karl DeSaulniers 
>> 
>>> On Sep 20, 2016, at 3:22 AM, Lester Caine 
>>> wrote:
>>> 
 On 20/09/16 09:14, Karl DeSaulniers wrote:
 Pardon my ignorance, but what do you mean full path?
>>> Full path to php application.
>>> Cron jobs run as 'root' and so need and user account settings added
>>> manually if they do not match the 'root' environment.
>>> 
>> 
>> OH, ok, I did read something about root earlier.
>> I think it was something like:
>> 
>> root /usr/bin/php5 /home/(directory name removed)/auto_reminder.php
>> 
>> But not positive. I will have to research that more.
>> Thank you.
>> 
>> 
> 
> Whether cron jobs run as root or a standard user depends on how they
> are set up. If set up under a user -- which is the better approach
> for general use -- they will run as that user. Really only
> system-type cron jobs (that require root access) should be set up to
> run as root.
> 
> If you use the command: 
> 
>   crontab -e
> 
> from a user account, then the crontab is set up as that user. The
> first 5 fields/values are time/date related, followed by the command
> to be invoked. See: man -s5 crontab  for more details.
> 
> In that case, the user that mysql sees is the user that is running
> the job. So, if your mysql authentication is set to accept
> connections/give access to say the user your web server is running as
> (which is how php will show by default), then you will either need to
> pass those credentials in your cron job php script or, give the user
> that's running the cron job access.
> 

Again, thank you for the response Richard.

Would you possibly have a link to how to set that up? I mean the actual 
commands. My trouble is I don't know what commands and how to write them. Like 
including a user, forcing the PHP.ini and executing the script. All in one 
line. That is what I am trying to accomplish and not sure how. Need to read up 
on the proper way to do this. 

TIA,

Best,
Karl

Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
Hi Richard & Bert,
Thanks for the responses. I think I understand what you are both saying. 

Not sure where my database is housed as I am using a hosting provider 
(Mediatemple)
and they allow limited access to such things or I am unaware how to access them.

For my current issue, lets just say my username is  db123456
db123456 is the root user who has access to all databases
However I am not sure if the cron job runs under this user.

This is the command line I have currently that is not working

/usr/bin/php5 -c /home/123456/etc/php.ini | -f 
/home/123456/data/auto_reminder.php

My hosting company says I can force my php.ini with -c |
but this errors out saying -f command can not be found.

I tried this:

/usr/bin/php5 -c /home/123456/etc/php.ini | /home/123456/data/auto_reminder.php

but then I get the same error I originally had saying php doesn't exist.
I tried a semicolon like I had seen on some message boards and the double &&
but still no dice.

I even tried to set the user in the args like so

/usr/bin/php5 -c /home/123456/etc/php.ini ; /home/123456/data/auto_reminder.php 
-udb123456

again, no dice.

@Bert  
I think it may be that the cron is under another user and that my original CL 
works, just not sure how to find out.
I would call my hosting provider to ask, but I always get the same response ... 

We don't troubleshoot peoples code it is out of our scope of support.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com




> On Sep 20, 2016, at 1:07 PM, Richard 
>  wrote:
> 
> 
> 
>  Original Message 
>> Date: Tuesday, September 20, 2016 12:54:38 -0500
>> From: Karl DeSaulniers 
>> 
>> On Sep 20, 2016, at 7:21 AM, Richard
>>  wrote:
>>> 
>>> 
>>> 
 Date: Tuesday, September 20, 2016 03:26:39 -0500
 From: Karl DeSaulniers 
 
> On Sep 20, 2016, at 3:22 AM, Lester Caine 
> wrote:
> 
>> On 20/09/16 09:14, Karl DeSaulniers wrote:
>> Pardon my ignorance, but what do you mean full path?
> Full path to php application.
> Cron jobs run as 'root' and so need and user account settings
> added manually if they do not match the 'root' environment.
> 
 
 OH, ok, I did read something about root earlier.
 I think it was something like:
 
 root /usr/bin/php5 /home/(directory name
 removed)/auto_reminder.php
 
 But not positive. I will have to research that more.
 Thank you.
 
 
>>> 
>>> Whether cron jobs run as root or a standard user depends on how
>>> they are set up. If set up under a user -- which is the better
>>> approach for general use -- they will run as that user. Really only
>>> system-type cron jobs (that require root access) should be set up
>>> to run as root.
>>> 
>>> If you use the command: 
>>> 
>>>  crontab -e
>>> 
>>> from a user account, then the crontab is set up as that user. The
>>> first 5 fields/values are time/date related, followed by the
>>> command to be invoked. See: man -s5 crontab  for more details.
>>> 
>>> In that case, the user that mysql sees is the user that is running
>>> the job. So, if your mysql authentication is set to accept
>>> connections/give access to say the user your web server is running
>>> as (which is how php will show by default), then you will either
>>> need to pass those credentials in your cron job php script or,
>>> give the user that's running the cron job access.
>>> 
>> 
>> Again, thank you for the response Richard.
>> 
>> Would you possibly have a link to how to set that up? I mean the
>> actual commands. My trouble is I don't know what commands and how
>> to write them. Like including a user, forcing the PHP.ini and
>> executing the script. All in one line. That is what I am trying to
>> accomplish and not sure how. Need to read up on the proper way to
>> do this. 
>> 
> 
> The php.ini that is used will be based on the php rules for the
> path(s) (and order) it searches for that file.
> 
> The user that is running the script will be the user that the cron
> job is set up under. If you set up a cron job as a standard user you
> can't assign it to run as a different user. If the issue is mysql
> access, you do that just the way you would in a [web]server parsed
> php file.
> 
> The script is whatever you put on the crontab line.
> 
> The script you reference from the crontab entry can be a shell script
> that does some setup, and then calls your php script.  Your php
> script can have include files (e.g., for mysql connection setup) just
> as you might have in a [web]server parsed php file.
> 
> 
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread B. Aerts

On 20/09/16 10:06, Lester Caine wrote:

On 20/09/16 06:16, Karl DeSaulniers wrote:

Was probably a newb question, however, now it is saying that my database user 
is not allowed access.
I have a mysql connection inside my script that reads the database to get user 
email addresses to send a reminder email to.

Is there supposed to be a call or directive to load mysql in my command line as 
well?
Man this is frustrating.


The user name and password you are using from the web scripts SHOULD
work in the script you are using on the cron job. Although mysql does
seem to have a few extra security features that cut in. Are they listed
in the script, or loaded from the environment ... which is of cause
different for the cron jobs ... and why you needed the full path.



Karl,

is your MySQL database located on the machine itsself where you run the 
Cron job ?
If so, does your Cron user have read/write/execute permissions on either 
the DB directory, and the DB itsself ?


Regards, Bert

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Peter Beckman

I suspect you are taking the pipe or semicolon literally.

Drop the pipe and semicolon entirely. This should work:

/usr/bin/php5 -c /home/123456/etc/php.ini -f 
/home/123456/data/auto_reminder.php

The "pipe" (|) in unix (and I assume this is unix) means to pipe the output
of php5 -c config to the command "-f /home...php". Which (-f) isn't a command.

The "semicolon" (;) in unix means "do this command first; then do this command"
so in your second part it is running 
/home/123456/data/auto_reminder.php -udb123456  after it runs php5.


Usually php5 -c php.ini will run PHP in interactive mode, and sits and
waits for input. When run from cron, there is no input, so it dies, unable
to pipe the output (there is none) or just run the next command.

So -- lose the pipe, lose the semicolon, just run the command above in cron
(and on the command line) and it should "just work."

Beckman

On Tue, 20 Sep 2016, Karl DeSaulniers wrote:


Hi Richard & Bert,
Thanks for the responses. I think I understand what you are both saying.

Not sure where my database is housed as I am using a hosting provider 
(Mediatemple)
and they allow limited access to such things or I am unaware how to access them.

For my current issue, lets just say my username is  db123456
db123456 is the root user who has access to all databases
However I am not sure if the cron job runs under this user.

This is the command line I have currently that is not working

/usr/bin/php5 -c /home/123456/etc/php.ini | -f 
/home/123456/data/auto_reminder.php

My hosting company says I can force my php.ini with -c |
but this errors out saying -f command can not be found.

I tried this:

/usr/bin/php5 -c /home/123456/etc/php.ini | /home/123456/data/auto_reminder.php

but then I get the same error I originally had saying php doesn't exist.
I tried a semicolon like I had seen on some message boards and the double &&
but still no dice.

I even tried to set the user in the args like so

/usr/bin/php5 -c /home/123456/etc/php.ini ; /home/123456/data/auto_reminder.php 
-udb123456

again, no dice.

@Bert
I think it may be that the cron is under another user and that my original CL 
works, just not sure how to find out.
I would call my hosting provider to ask, but I always get the same response ...

We don't troubleshoot peoples code it is out of our scope of support.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com





On Sep 20, 2016, at 1:07 PM, Richard  
wrote:



 Original Message 

Date: Tuesday, September 20, 2016 12:54:38 -0500
From: Karl DeSaulniers 

On Sep 20, 2016, at 7:21 AM, Richard
 wrote:





Date: Tuesday, September 20, 2016 03:26:39 -0500
From: Karl DeSaulniers 


On Sep 20, 2016, at 3:22 AM, Lester Caine 
wrote:


On 20/09/16 09:14, Karl DeSaulniers wrote:
Pardon my ignorance, but what do you mean full path?

Full path to php application.
Cron jobs run as 'root' and so need and user account settings
added manually if they do not match the 'root' environment.



OH, ok, I did read something about root earlier.
I think it was something like:

root /usr/bin/php5 /home/(directory name
removed)/auto_reminder.php

But not positive. I will have to research that more.
Thank you.




Whether cron jobs run as root or a standard user depends on how
they are set up. If set up under a user -- which is the better
approach for general use -- they will run as that user. Really only
system-type cron jobs (that require root access) should be set up
to run as root.

If you use the command:

 crontab -e

from a user account, then the crontab is set up as that user. The
first 5 fields/values are time/date related, followed by the
command to be invoked. See: man -s5 crontab  for more details.

In that case, the user that mysql sees is the user that is running
the job. So, if your mysql authentication is set to accept
connections/give access to say the user your web server is running
as (which is how php will show by default), then you will either
need to pass those credentials in your cron job php script or,
give the user that's running the cron job access.



Again, thank you for the response Richard.

Would you possibly have a link to how to set that up? I mean the
actual commands. My trouble is I don't know what commands and how
to write them. Like including a user, forcing the PHP.ini and
executing the script. All in one line. That is what I am trying to
accomplish and not sure how. Need to read up on the proper way to
do this.



The php.ini that is used will be based on the php rules for the
path(s) (and order) it searches for that file.

The user that is running the script will be the user that the cron
job is set up under. If you set up a cron job as a standard user you
can't assign it to run as a different user. If the issue is mysql
access, you do that just the way you would in a 

Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers

> On Sep 20, 2016, at 10:09 PM, Peter Beckman  wrote:
> 
> I suspect you are taking the pipe or semicolon literally.
> 
> Drop the pipe and semicolon entirely. This should work:
> 
>/usr/bin/php5 -c /home/123456/etc/php.ini -f 
> /home/123456/data/auto_reminder.php
> 
> The "pipe" (|) in unix (and I assume this is unix) means to pipe the output
> of php5 -c config to the command "-f /home...php". Which (-f) isn't a command.
> 
> The "semicolon" (;) in unix means "do this command first; then do this 
> command"
> so in your second part it is running /home/123456/data/auto_reminder.php 
> -udb123456  after it runs php5.
> 
> Usually php5 -c php.ini will run PHP in interactive mode, and sits and
> waits for input. When run from cron, there is no input, so it dies, unable
> to pipe the output (there is none) or just run the next command.
> 
> So -- lose the pipe, lose the semicolon, just run the command above in cron
> (and on the command line) and it should "just work."
> 
> Beckman
> 
> 


Hey thanks Peter for clearing that up. Yes, I was taking the pipe and semicolon 
literally.
I have since found this out on my own that my original code works. It is as 
Richard and Bert had said.
My cron runs under the server admin user and so I have to contact my client to 
find out what that password is or change it.

Much thanks to everyone for your time and responses with my issue. You guys are 
invaluable!

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php