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 6915575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:29:32+00:00 2026-05-27T09:29:32+00:00

I am having trouble with a script that checks the date of a table

  • 0

I am having trouble with a script that checks the date of a table to make sure the slave’s data is up to date

The problem is that the date equality is coming back incorrect:

NOW=$(date +"%Y-%m-%d")
VALUE=`mysql -uroot -p database -e "select DATE_FORMAT(create_date,'%Y-%m-%d') as '' from actions order by id desc limit 1"`
echo $NOW $VALUE
if [ "$?" -ne 0 ]; then
   MSG="MySQL check data date failed"
   echo $MSG
   echo $MSG > $MESSAGE
   /bin/mail -s "$SUBJECT" "$EMAIL" < $MESSAGE
   exit 7
fi
if [ "$NOW" != "$VALUE" ]; then
   echo "not equal"
fi

The output is that they are not equal:

2011-12-08 2011-12-08
not equal

My guess is that I am comparing two different types, but according the bash documentation that shouldn’t be the case.
Can someone explain this to me?
Thanks

  • 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-05-27T09:29:33+00:00Added an answer on May 27, 2026 at 9:29 am

    If you turn on the shell debugging set -vx, you’ll see each line (or block of code like while, for loops) displayed, (verbose mode), then you get the line as it being executed with all variables expanded to their current values. Change the last conditional to

    if [ "X${NOW}X" != "X${VALUE}X" ] ; then ....
    

    And you can easily tell if $NOW or $VALUE have any extra while-space characters embedded. Once you can see where the differences are, then you can easily determine how to fix the assignment of those values.

    I hope this helps.

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

Sidebar

Related Questions

I am having trouble coming up with a jQuery script that will all content
I'm having some trouble figuring this out. I have a script that checks a
I'm having trouble running powershell with a script that should use a variable number
I'm having trouble converting this 5 star rating script that works perfect with jquery
I'm having trouble modifying a script that processes files passed as command line arguments,
I am having trouble putting together a script that lists various business contact information.
I'm having trouble with this PHP script where I get the error Fatal error
I'm having little trouble creating a script working with URLs. I'm using urllib.urlopen() to
I'm trying to translate a Perl script to PHP and I'm having trouble with
I'm having terrible trouble trying to understand python scoping rules. With the following script:

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.