MySQL Exporting a query to text file via Cron Job I'm in the beginning stages of hacking together code that syncs two completely different pieces of software/webware. I'm looking for a way to run a SQL query and output the results to a text file. I'd like this information to be updated daily so I'm leaning towards a cron job.

My current line of thought is to just write a script that logs into the database(phpBB) run the query (All users that have X number of posts) and then export that list of users to a text file.

My question/s:


Do I have to worry about putting the database username/password into this cron script?
Is there another more efficient way for me to get this information from the database without logging into MySQL?
Is Cron jobs appropriate for retrieving information from a database?
Is there any MySQL specific cron/scripting issues I need to be aware of while programing this.


Please keep in mind that I will be using linux to code and execute this script and the MySQL server is hosted on a unix machine.
After talking to someone more knowledgeable then me I have came up with the following answers to my original questions.
TLDR; Cron should be fine for what your doing but don't write a bash script, write a PHP script instead, it's better.

Q1. Do I have to worry about putting the database username/password into this &gt;cron script?

A1. As long as the script is in a safe spot on the server that is running the &gt;&gt;cron it should be fine. I can also create a new database user with very &gt;&gt;limited access specifically for this script.

Q2. Is there another more efficient way for me to get this information from &gt;the database without logging into MySQL?

A2. There is a more efficient way to get the information, MySQLi or PDO via a &gt;&gt;PHP script, but there is no way to get around logging in.

Q3. Is Cron jobs appropriate for retrieving information from a database?

A3. Cron jobs should work fine for running the script on a regular basis.

Q4. Is there any MySQL specific cron/scripting issues I need to be aware of &gt;while programing this.

A4. There isn't any cron specific issues but Bash or any other *nix based &gt;&gt;scripting language shouldn't be used because of limited access to MySQL. &gt;&gt;Instead a php script should be created utilizing either (PDO or MySQLi).


If anyone can answer the &quot;Why&quot; PHP is better then Bash Scripting in this scenario feel free to leave a post or comment.