Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.databases.mysql Subject: Re: From bash script (Debian Bookworm) login and query to MariaDB Date: Thu, 2 Nov 2023 12:22:01 +0100 Lines: 43 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net hwDg/5AN0KN6xJtqnGudjg8GJSQ9YQU3OFzrWLA3lK6R4jukC5 Cancel-Lock: sha1:rjkuyHzlAyfWYK6gVYU0YuJg2qQ= sha256:LrOu09UmzVR9VN4vRYYlD1bcNGQV29NFaWx6Yi0/V7Q= User-Agent: Mozilla Thunderbird Content-Language: en-US-large In-Reply-To: Xref: csiph.com comp.databases.mysql:7671 On 02/11/2023 11.46, ^Bart wrote: >> Thanks for your reply, I used PHP years and years ago and I don't >> remember it very well but really thanks to share this solution! :) > > I did in my crontab this: > > */5 * * * * /usr/bin/mysql -u my_username -h localhost -p my_password < > /home/itoffice/query.sql this in /etc/crontab or did you use it as your personal crontab with "crontab -e"? if the later, then your user need to have the right to read the file and of course have the right to access the content in the itoffice directory. if /etc/crontab then add who is executing the command and it can be good to put parentheses around command too */5 * * * * (root) (/usr/bin/mysql -umy_username -pmy_password databasename < /home/itoffice/query.sql) > I think I must use php like what this site said: > https://stackoverflow.com/questions/9948220/how-can-i-set-a-crontab-to-execute-a-mysql-query-and-log-the-output No you don't, it's just what he did. > I think also I should save php file not in my home folder like > /home/itoffice but in /var/www/html right? That is much about how you use the php script, if you use it like a bash script then no you don't put it there. If it's part of your web site, then yes. Php can be used for websites, scripting and even create gui applications, it may not be the best option in all situations. -- //Aho