Link to home
Start Free TrialLog in
Avatar of sharkbot221984
sharkbot221984Flag for United States of America

asked on

help with cron job and mysql export

Hi I have a series of tasks I need to perform to A: export data form a table to a csv file, B: strip the header of the file out, C: copy the file via SSH to another (linux) server.

I know all the commands and can complete all these task on their own from bash, but I want to string them together and be able to schedule a one time (as needed) cron job to execute each task in succession as these tasks need to be done over night.

The commands I use are:
A: mysql -u root -p --quick databasename -e "select * from tablename" | sed 's/\t/;/g' > file.csv
B: tail -n +2 file.csv > file_noheader.csv
C: rsync -e ssh -av file_noheader root@server:/path/file_noheader.csv
ASKER CERTIFIED SOLUTION
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of ajay_mhasal
ajay_mhasal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial