Re: [PHP-DB] Corn job anomaly
> On Sep 27, 2016, at 2:24 AM, Ford, Mike <m.f...@leedsbeckett.ac.uk> wrote: > >> -Original Message- >> From: Karl DeSaulniers [mailto:k...@designdrumm.com] >> Sent: 25 September 2016 09:59 >> To: PHP List Database <php-db@lists.php.net> >> Subject: Re: [PHP-DB] Corn job anomaly >> >> Now I am getting an error with mysql syntax. >> >> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf >> ON cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND >> cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND >> otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'" >> >> is giving me this error: >> You have an error in your SQL syntax; check the manual that >> corresponds to your MySQL server version for the right syntax to use near >> '\"Shipping\" AND otn.Order_Status != \"Completed\"' at line 1 > > I don't think INTERVAL works like that - you probably need something like: > >... cf.Earliest_Pickup <= DATE_ADD(CURDATE(), INTERVAL > ".($Num_Days_Away+1)." DAY) AND ... > > Incidentally, as I understand it CURDATE() does exactly the same as > DATE(NOW()), and is probably more readable. > > Cheers! > > Mike > > -- > Mike Ford, Hi Mike, I figured out what was wrong with my script on that error. I had mysqli_real_escape_string() wrapping the whole select statement. The INTERVAL part I got from PHP.net and it is working just fine. Just fyi. Once I wrapped just ($Num_Days_Away+1) part it started working. Thanks for responding! 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
> -Original Message- > From: Karl DeSaulniers [mailto:k...@designdrumm.com] > Sent: 25 September 2016 09:59 > To: PHP List Database <php-db@lists.php.net> > Subject: Re: [PHP-DB] Corn job anomaly > > Now I am getting an error with mysql syntax. > > "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf > ON cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND > cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND > otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'" > > is giving me this error: > You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server version for the right syntax to use near > '\"Shipping\" AND otn.Order_Status != \"Completed\"' at line 1 I don't think INTERVAL works like that - you probably need something like: ... cf.Earliest_Pickup <= DATE_ADD(CURDATE(), INTERVAL ".($Num_Days_Away+1)." DAY) AND ... Incidentally, as I understand it CURDATE() does exactly the same as DATE(NOW()), and is probably more readable. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, 110 Queen Square House, 80 Woodhouse Lane, Leeds Beckett University, Leeds LS2 8NU, United Kingdom E & S4B: m.f...@leedsbeckett.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to:- http://disclaimer.leedsbeckett.ac.uk/disclaimer/disclaimer.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Corn job anomaly
Oops. I actually ran it with single and double quotes and got the same error both times. I am using single quotes originally. I think the query is getting the \ (backslash) read literally. I did not add those manually. Best, Karl Sent from losPhone > On Sep 25, 2016, at 9:17 AM, Richard > <inbound-lists-...@listmail.innovate.net> wrote: > > > >> Date: Sunday, September 25, 2016 08:37:14 -0400 >> From: Aziz Saleh <azizsa...@gmail.com> >> Subject: Re: [PHP-DB] Corn job anomaly >> >> On Sun, Sep 25, 2016 at 4:59 AM, Karl DeSaulniers >> <k...@designdrumm.com> wrote: >> >>>> On Sep 23, 2016, at 5:38 AM, Richard wrote: >>>> >>>> -- Try the mysql access and commands directly from the command >>>> line (using the mysql cli). >>>> >>>> -- Put debug/print statements in your code so you can clearly >>>> see where you are getting. >>>> >>>> -- This includes printing out your mysql statements so that >>>> you know exactly what is being passed to mysql (both when >>>> you run the script by hand and via cron). >>>> >>> >>> Thanks Richard, >>> That got me thinking and I figured out my access issue... >>> HALELUYA! >>> >>> Now I am getting an error with mysql syntax. >>> >>> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN >>> ".FIELDS_TABLE." cf ON cf.Order_ID = otn.Order_ID WHERE >>> cf.Earliest_Pickup >= DATE(NOW()) AND cf.Earliest_Pickup <= >>> DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND >>> otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'" >>> >>> is giving me this error: >>>You have an error in your SQL syntax; check the manual that >>> corresponds to your MySQL server version for the right syntax to >>> use near '\"Shipping\" AND otn.Order_Status != \"Completed\"' at >>> line 1 >>> >>> >> >> Echo out the query, then manually run it. >> > > Based on the quoting, it doesn't appear that the error you are > reporting is actually based on the command syntax you are showing. > > If after echoing your mysql query, so that you see all substitutions, > you are still having trouble, then take your query apart and simplify > it. When you get a trimmed down version to work, then add complexity. > > > > > -- > 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
> Date: Sunday, September 25, 2016 08:37:14 -0400 > From: Aziz Saleh <azizsa...@gmail.com> > Subject: Re: [PHP-DB] Corn job anomaly > > On Sun, Sep 25, 2016 at 4:59 AM, Karl DeSaulniers > <k...@designdrumm.com> wrote: > >> > On Sep 23, 2016, at 5:38 AM, Richard wrote: >> > >> > -- Try the mysql access and commands directly from the command >> >line (using the mysql cli). >> > >> > -- Put debug/print statements in your code so you can clearly >> >see where you are getting. >> > >> >-- This includes printing out your mysql statements so that >> > you know exactly what is being passed to mysql (both when >> > you run the script by hand and via cron). >> > >> >> Thanks Richard, >> That got me thinking and I figured out my access issue... >> HALELUYA! >> >> Now I am getting an error with mysql syntax. >> >> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN >> ".FIELDS_TABLE." cf ON cf.Order_ID = otn.Order_ID WHERE >> cf.Earliest_Pickup >= DATE(NOW()) AND cf.Earliest_Pickup <= >> DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND >> otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'" >> >> is giving me this error: >> You have an error in your SQL syntax; check the manual that >> corresponds to your MySQL server version for the right syntax to >> use near '\"Shipping\" AND otn.Order_Status != \"Completed\"' at >> line 1 >> >> > > Echo out the query, then manually run it. > Based on the quoting, it doesn't appear that the error you are reporting is actually based on the command syntax you are showing. If after echoing your mysql query, so that you see all substitutions, you are still having trouble, then take your query apart and simplify it. When you get a trimmed down version to work, then add complexity. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Corn job anomaly
On Sun, Sep 25, 2016 at 4:59 AM, Karl DeSaulnierswrote: > > On Sep 23, 2016, at 5:38 AM, Richard innovate.net> wrote: > > > > > > > >> Date: Friday, September 23, 2016 03:28:47 -0500 > >> From: Karl DeSaulniers > >> > >> Ok, so I have run down all the possible things (that I know of) > >> that could be keeping this from working. I have checked with my > >> hosting service that: > >> > >> 1. MySQL is accessible with the original user I started with (for > >> this case were using db123456) via ssh. 2. The cron is accessing my > >> php script fine. > >> 3. The cron is running the script and is attempting to access MySQL > >> but not allowing access still. > >> > >> I tried running the script via ssh and it is timing out. No error > >> of not accessing MySQL, just telling me it is timing out. This > >> tells me (I could be wrong) that it is in fact accessing MySQL and > >> that my calls to MySQL are making the script time out? What bothers > >> me is that the cron errors out saying access denied but ssh says > >> timeout error. Does anyone have any ideas for me to try at this > >> point? If I don't get this to work in the next couple of days, I am > >> toast! > >> > > > > -- Try the mysql access and commands directly from the command > >line (using the mysql cli). > > > > -- Put debug/print statements in your code so you can clearly > >see where you are getting. > > > >-- This includes printing out your mysql statements so that > > you know exactly what is being passed to mysql (both when > > you run the script by hand and via cron). > > > > Thanks Richard, > That got me thinking and I figured out my access issue... HALELUYA! > > Now I am getting an error with mysql syntax. > > "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf > ON cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND > cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND > otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'" > > is giving me this error: > You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server version for the right syntax to use near > '\"Shipping\" AND otn.Order_Status != \"Completed\"' at line 1 > > I think at this point my brain is fried and I am not seeing what is wrong > with this. > Can anyone point out my folly? My guess is it is an obvious one, but I am > not seeing it. > > Thanks again for your help everyone. I think I am almost there! > > 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 > > Echo out the query, then manually run it.
Re: [PHP-DB] Corn job anomaly
> On Sep 23, 2016, at 5:38 AM, Richard >wrote: > > > >> Date: Friday, September 23, 2016 03:28:47 -0500 >> From: Karl DeSaulniers >> >> Ok, so I have run down all the possible things (that I know of) >> that could be keeping this from working. I have checked with my >> hosting service that: >> >> 1. MySQL is accessible with the original user I started with (for >> this case were using db123456) via ssh. 2. The cron is accessing my >> php script fine. >> 3. The cron is running the script and is attempting to access MySQL >> but not allowing access still. >> >> I tried running the script via ssh and it is timing out. No error >> of not accessing MySQL, just telling me it is timing out. This >> tells me (I could be wrong) that it is in fact accessing MySQL and >> that my calls to MySQL are making the script time out? What bothers >> me is that the cron errors out saying access denied but ssh says >> timeout error. Does anyone have any ideas for me to try at this >> point? If I don't get this to work in the next couple of days, I am >> toast! >> > > -- Try the mysql access and commands directly from the command >line (using the mysql cli). > > -- Put debug/print statements in your code so you can clearly >see where you are getting. > >-- This includes printing out your mysql statements so that > you know exactly what is being passed to mysql (both when > you run the script by hand and via cron). > Thanks Richard, That got me thinking and I figured out my access issue... HALELUYA! Now I am getting an error with mysql syntax. "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf ON cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'" is giving me this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\"Shipping\" AND otn.Order_Status != \"Completed\"' at line 1 I think at this point my brain is fried and I am not seeing what is wrong with this. Can anyone point out my folly? My guess is it is an obvious one, but I am not seeing it. Thanks again for your help everyone. I think I am almost there! 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
> Date: Friday, September 23, 2016 03:28:47 -0500 > From: Karl DeSaulniers> > Ok, so I have run down all the possible things (that I know of) > that could be keeping this from working. I have checked with my > hosting service that: > > 1. MySQL is accessible with the original user I started with (for > this case were using db123456) via ssh. 2. The cron is accessing my > php script fine. > 3. The cron is running the script and is attempting to access MySQL > but not allowing access still. > > I tried running the script via ssh and it is timing out. No error > of not accessing MySQL, just telling me it is timing out. This > tells me (I could be wrong) that it is in fact accessing MySQL and > that my calls to MySQL are making the script time out? What bothers > me is that the cron errors out saying access denied but ssh says > timeout error. Does anyone have any ideas for me to try at this > point? If I don't get this to work in the next couple of days, I am > toast! > -- Try the mysql access and commands directly from the command line (using the mysql cli). -- Put debug/print statements in your code so you can clearly see where you are getting. -- This includes printing out your mysql statements so that you know exactly what is being passed to mysql (both when you run the script by hand and via cron). -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Corn job anomaly
Ok, so I have run down all the possible things (that I know of) that could be keeping this from working. I have checked with my hosting service that: 1. MySQL is accessible with the original user I started with (for this case were using db123456) via ssh. 2. The cron is accessing my php script fine. 3. The cron is running the script and is attempting to access MySQL but not allowing access still. I tried running the script via ssh and it is timing out. No error of not accessing MySQL, just telling me it is timing out. This tells me (I could be wrong) that it is in fact accessing MySQL and that my calls to MySQL are making the script time out? What bothers me is that the cron errors out saying access denied but ssh says timeout error. Does anyone have any ideas for me to try at this point? If I don't get this to work in the next couple of days, I am toast! TIA, 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
> On Sep 20, 2016, at 10:09 PM, Peter Beckmanwrote: > > 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
Re: [PHP-DB] Corn job anomaly
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, Richardwrote: 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
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
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
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
On Sep 20, 2016, at 7:21 AM, Richardwrote: > > > >> 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
> 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
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
> On Sep 20, 2016, at 3:22 AM, Lester Cainewrote: > > 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
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
> On Sep 20, 2016, at 3:14 AM, Karl DeSaulnierswrote: > >> 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] Corn job anomaly
> On Sep 20, 2016, at 3:06 AM, Lester Cainewrote: > > 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] Corn job anomaly
> On Sep 20, 2016, at 3:06 AM, Lester Cainewrote: > > 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
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
> On Sep 20, 2016, at 12:16 AM, Karl DeSaulnierswrote: > >> 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
> 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Corn job anomaly
> 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. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php