Question

The content of the shell script is like this :

date
cur_date=`date '+%Y-%m-%d'` 
cur_time=`date '+%Y-%m-%d %H %M %S'`
start_date='2014-01-01'  
end_date=`date '+%Y-%m-%d'`
FiveDaysBack=`date --date='-7 day' "+%Y-%m-%d"`

rm -f *.sql
mysqldump -h192.168.200.150 torr > torr1.sql &
mysqldump -h192.168.200.100 torr > torr2.sql &
...
...
...
wait && echo `date` complete.

I'm running this script as :

nohup sh etl.sh &

Executing the script results in all the sql dump going into the nohup.out file and not to the torr1.sql, torr2.sql et all. So I get a huge nohup.out file where I wanted the dump to go the torr.sql files.

Please note that this script does a lot more than this and I'm not looking for an alternate arrangement for obtaining mysql dumps. All I'd like to know is why is the mysqldump output not going into the specified files and instead being directed to nohup.out. I'd like to resolve just that.

Was it helpful?

Solution 3

Okay, this is going to sound stupid.
1. sorry for not pasting the entire command, Walter and philshem. Perhaps it would have helped.
2. The entire command was :

mysqldump --insert-ignore --skip-add-drop-table --no-create-info --lock-tables=false -ucrbt_se -pcrbt_se -h10.2.2.150 blah master_backup --where "date(END_TIME)>='$FiveDays'" --result-file=torr1.sql 

and Nano was wrapping the text around. As a result of the large size of the dump, I had never waited to see the error that MySQL threw in the end, which indicated the wrong parameter to the command.

2 days wasted. Damn.

OTHER TIPS

Re-answer:

I'd use 'screen' instead of 'nohup'. It's a more powerful solution that allows you to revisit your active terminal if it is closed. See here or here for a discussion.

The last line should be with two & characters: wait && echo $(date) complete.

This still does not answer your problem. Maybe mysqldump writes to stderr or your etl.sh did something funny with the stdout.

I reproduced your problem with this script:

sleep 10
rm non_existing > stdout.txt

I started this script (I saved it as rm_nothing.sh) with

 nohup rm_nothing.sh

The output of rm did not appear in stdout.txt.

Please try to add 2>&1

mysqldump -h192.168.200.150 torr > torr1.sql 2>&1 &
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top