LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 11-04-2003, 08:02 AM   #1
fallen
LQ Newbie
 
Registered: Oct 2003
Location: UK
Distribution: I don't really but RH7.1 for now
Posts: 3

Rep: Reputation: 0
Question Mysql Cron Script using select not working


Hi all,

Apologies if there is an obvious solution to this but I honestly can't see it.

I have a shell script which takes for tables from a mysql db and inserts them into an email and sends them to a given user. It works when run from the command line.

I set up a cron job to fire this script once a week at 1am on Sunday. When the cron jobs runs the emails are sent but are empty. The select doesn't seem to work.

Both scripts are run by root either on the command line or in roots crontab so it shouldn't be a permissions thing?

Any ideas or further questions are welcome.

Sam
 
Old 11-04-2003, 08:12 AM   #2
fallen
LQ Newbie
 
Registered: Oct 2003
Location: UK
Distribution: I don't really but RH7.1 for now
Posts: 3

Original Poster
Rep: Reputation: 0
Sorry I neglected to mention that the email address is hard coded.

====================Script======================
# Send users table
echo "To:some@email.co.uk;
Subject:'Users table'" > ./mailtemp;
mysql -e "select * from dbname.users" -u someuser --password='somepw' >> ./mailtemp;
/usr/lib/sendmail -t -oi < ./mailtemp;
rm -f ./mailtemp;
====================Script======================

==================Cron Entry====================
################### Data Dump
0 1 * * 0 /scriptlocation/dumpscript.sh
==================Cron Entry====================

The script fires at the right time and send out empty emails.

Sam

Last edited by fallen; 11-04-2003 at 08:13 AM.
 
Old 11-04-2003, 08:37 AM   #3
fallen
LQ Newbie
 
Registered: Oct 2003
Location: UK
Distribution: I don't really but RH7.1 for now
Posts: 3

Original Poster
Rep: Reputation: 0
Found the answer in another forum.

Wasn't using the full path for mysql, it was following shortcuts from the command line, but couldn't do that from the cron.

If anyone wants to explain the rationale behind that I'd love to know!
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 09:09 AM
php mysql select msound Programming 9 05-21-2005 09:44 PM
Mysql SELECT WHERE LIKE ivanatora Linux - Software 3 03-20-2005 12:43 PM
SELECT on MySQL Help Gerardoj Programming 5 05-29-2004 03:17 AM
mysql replicates, possible to SELECT only one per value? SerfurJ Programming 7 03-26-2004 12:35 PM


All times are GMT -5. The time now is 10:08 PM.

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