making shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting making shell script
# 1  
Old 12-15-2008
Bug making shell script

Hi ,
I am new to shell scripting I want to make script as to execute followng command

mysqldump -u (user name) -p(password) database name>filename.sql

this file saves with current date and time

and execute automatically at particular time which I give
# 2  
Old 12-15-2008
Will it execute the same time every day? Then you should add it to cron. (You'll need to search the forums or FAQ for how to do that.)

To make the script, just edit a file and name it "backupmysql.sh" or something. Then cut-and-paste and edit the fields to suit your needs:
Code:
#!/bin/sh
USER="www"
PASS="xxxx"
DB="zzzz"
DATE=`date +%y-%j`
mysqldump -u $USER -p$PASS $DB >backup-$DATE.sql

# 3  
Old 12-15-2008
Bug

I made shell script but when I execute through shell command it execute successfully but when when i use crontab it execute the backup but shows 0 kb I did following step

step 1 : my shell script is

#! /bin/sh
USER="root"
PASS="nxsmasc"
DB="sme"

DATE=`date +%y-%d-%m`
#date=`date +%F%R` #space between date and +
#longdate=`date +%m%d%y%h%mm%ss`
mysqldump -u $USER -p$PASS $DB>/home/today_sme-$DATE.sql

echo "done"

I stored this file as /usr/bin/bck_sme.sh

step 2: when i execute comand sh bck_sme.sh it excutes successfully

step 3: now through crontab

typed command crontab -e

following entry
29 19 * 12 0-6 /usr/bin/bck_script.sh

but when it execute it shows 0 k file

Please tell where could be problem
# 4  
Old 12-15-2008
check your mail box, read error message. maybe you will find a way
# 5  
Old 12-15-2008
Bug

Quote:
Originally Posted by ivhb
check your mail box, read error message. maybe you will find a way
as i checked mail following found

Subject: Cron <root@ninex> /usr/bin/bck_script.sh
Date: Mon, 15 Dec 2008 20:01:01 0530 (IST)
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>

/usr/bin/bck_script.sh: line 12: mysqldump: command not found
done


but this execute by command sh bck_script.sh
not through crontab
# 6  
Old 12-15-2008
As always, read the FAQ first!
# 7  
Old 12-15-2008
You just have to fix your PATH variable. When you are the command prompt, type:
Code:
echo $PATH
echo $LD_LIBRARY_PATH

You'll need the contents of these either inside your script or inside your crontab.

ALSO, you're outputting to a file in /home. That's normally INCORRECT. Your output file should be something like:
Code:
 ...  >$HOME/today_sme-$DATE.sql

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help me making this script

This script is executed whenever a new vehicle is added to the cycle-motor park of campus. The script asks for the following information about the car and adds a new line to the vehicle file.txt: name (name of an animal, unique identifier), color, mark, model, type (e.g., electrical, manual),... (2 Replies)
Discussion started by: andre2222
2 Replies

2. Shell Programming and Scripting

Need Help With making this script

Hello, im a new user on this site and learning scripting very slowly at a understanding pace. However i am up with a challenge and require help completing this. The script has to include arguments, variables, decisions and loops. So the script is about calculating the broadcast address for any... (5 Replies)
Discussion started by: tHe666
5 Replies

3. Shell Programming and Scripting

Using shell scripting for making queries on postgres sql

I have a situation where I have a list of airplanes that make a series of flights. Therefore I am looking up the different flights that each airplane makes based on a postgres sql query: select flightid from plane where airplane='DELTAx' As a result I get a series of flight numbers... (0 Replies)
Discussion started by: JSNY
0 Replies

4. Shell Programming and Scripting

I could use some help with making a script

I run a small instrument lab. We track our user's time on the instruments with a very manual process of 'last wtmp.1' then cut/paste data into spreadsheets. My boss makes the initial spreadsheets then I convert and format them for uploading into our billing software (COReS). Cores is looking for a... (8 Replies)
Discussion started by: jpontius
8 Replies

5. Shell Programming and Scripting

shell script with decision making

Hi all I need help for the issue below. I need to create script: FORM_cmd=query || import FORM_command=add FORM_msisdn=389881234567 FORM_provcode=SK FORM_attr=12 FORM_cmd can be "query" or "import" when FORM_cmd="query" then execute -> spdci -cmd $FORM_cmd FORM_cmd when... (3 Replies)
Discussion started by: vasil
3 Replies

6. Shell Programming and Scripting

Making file inside shell script

Hi, i have written a shell script and its working fine till now. Now, i have to enhance it with a small updation. i need to make a file inside my file that will contain the below parameters 1) Customer_id 2) Server_id 3) No. Account All the above variables are already been taken in... (3 Replies)
Discussion started by: dazdseg
3 Replies

7. Shell Programming and Scripting

Problem in making shell script

Dear all Dear Brother I am bit new to programming or shell scripting. I have given one shell script which is regarding combining all the 240 or less files in a particular folderwhich is related to one hour of the day. There will be 24 these kind of folders related to a day . It means there... (4 Replies)
Discussion started by: girish.batra
4 Replies

8. Shell Programming and Scripting

making script

hello experts cany any one help me i want to make one script which can rlogin to another machine . but it should not ask me username/password from me of another machine it should take the username and password from the script only. please help me out. regards, shary (2 Replies)
Discussion started by: shary
2 Replies

9. Shell Programming and Scripting

Need help making a script

Here is what I have: #!/bin/bash # Setup year date and month YR=`date +%Y '{print $6}'` MON=`date +%b '{print $2}'` DAY=`date +%d '{print $3}'` file=$YR$MOY$DOM # clear # Dump database using USER/PASS to ..sql mysqldump --user=me -ppass database > database-db.$file.sql The YR, MON and... (2 Replies)
Discussion started by: npereira
2 Replies

10. Shell Programming and Scripting

Making a SOAP call from within unix shell scripts

Hi guys, Is it possible to make SOAP calls from within Unix shell scripts? I need to access a web service from within UNIX in order to lookup something while I am doing some parsing on a file. Regards, Laud (2 Replies)
Discussion started by: Laud12345
2 Replies
Login or Register to Ask a Question