Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 09-02-2010, 04:52 PM   #1
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
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.
Old 09-02-2010, 10:51 PM   #2
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,125

Rep: Reputation: 165Reputation: 165
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.
1 members found this post helpful.
Old 09-03-2010, 09:19 AM   #3
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Original Poster
Rep: Reputation: 35

Will try this.

Added export MYSQL_HOME=/home/<user_running_cron>


Last edited by cmnorton; 09-09-2010 at 04:48 PM. Reason: Add fix


cron, mycnf, mysql

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is mysql automatically logging me in without .my.cnf or my.cnf sections? alunduil Linux - Server 11 05-19-2010 11:52 AM
linux cron job duplicate job question cpthk Linux - Newbie 4 09-11-2009 08:52 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron job somsahi Linux - Software 2 10-24-2006 05:40 AM
What linux distro to pick for this job? mogwhy Linux From Scratch 2 03-02-2003 07:22 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:58 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration