LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How To Get Cron Job To Pick up ~/.my.cnf (https://www.linuxquestions.org/questions/linux-server-73/how-to-get-cron-job-to-pick-up-%7E-my-cnf-830021/)

cmnorton 09-02-2010 04:52 PM

How To Get Cron Job To Pick up ~/.my.cnf
 
My question is how do I get a cron job to pick up the user's ~/.my.cnf? If the user runs the shell script, everything is fine. The cron entry has the same user run the job, and I've tried #!/bin/bash -l in the shell script with no success.

Here are the details:

I have a bash shell script that launches a Python program.
The python program issues an external shell mysql -e command.

I don't want the python code to use use -u user-name -pMyPassword, db-name, because this is contained in ~/.my.cnf. The python code doesn't have to use these parameters if run interactively, but does have to if run from cron.

I'm trying to find out why.

Thanks in advance for any help.

gilead 09-02-2010 10:51 PM

You should be able to manually set the environment variables that python is checking for in your script before running the python command. It's a bit of a pain to maintain them there as well as in your .bash_profile and/or .bashrc but it works for some scripts I run for starting things like Oracle and Tomcat.

cmnorton 09-03-2010 09:19 AM

Thanks
 
Will try this.

Edit:
-------------
Added export MYSQL_HOME=/home/<user_running_cron>

Worked.


All times are GMT -5. The time now is 02:19 AM.