Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9232231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:15:53+00:00 2026-06-18T06:15:53+00:00

I have the following commands in a shell script where I do a mysql

  • 0

I have the following commands in a shell script where I do a mysql dump, then I load that SQL file over ssh into a remote database, and then I update the timestamp.

1. mysqldump -u root files path | gzip -9 > $SQL_FILE
2. cat $SQL_FILE | ssh -i ~/metadata.pem ubuntu@1.2.3.4 
    "zcat | mysql -u 'root' -h 1.2.3.4 metadata"
3. TIMESTAMP=`date "+%Y-%m-%d-%T"`
4. mysql -u 'root' -h 1.2.3.4 metadata -e "UPDATE path_last_updated SET timestamp=DEFAULT"

Is there any way to improve the above commands. For example, what happens if line 2 fails (for example, due to a connectivity issue), but line 4 succeeds?

How would I make line 4 running conditional on the success of line 2?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:15:55+00:00Added an answer on June 18, 2026 at 6:15 am

    You could chain all in one block:

    mysqldump -u root files path |
        gzip -9 |
         ssh -i ~/metadata.pem ubuntu@1.2.3.4 "zcat |\
                       mysql -u 'root' -h 1.2.3.4 metadata"  &&
        mysql -u 'root' -h 1.2.3.4 metadata -e "
            UPDATE path_last_updated SET timestamp=DEFAULT"
    

    So last mysql command won’t be executed if something fail before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a shell script that includes the following command: /usr/local/bin/ssh -q -i /.ssh/id_rsa
I have the following python function that allows me to run shell commands from
I have the following two statements in a shell script: 32 /usr/local/mysql/bin/mysql -u root
I have the following to execute shell commands using Node: function puts( error, stdout,
I have the following commands in a README file: ./Setup ... ./Setup ... ./Setup
I have the following SQL command that I need to save as a csv
I have the following method for running shell commands in my java applications and
I have this shell script which executes the following command: #!/bin/sh echo -e {\username\:\user\,\password\:\mypasswd\,\data\
I have a config file that contains the following line: pre_args='$REGION','xyz',3 Using perl from
I have the following shell script. The purpose is to loop thru each line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.