Unable to subtract current date and future date in YYYY-MM-DD format
I want to write a script to calculate the difference between the current date and expiry date of a certificate and if the difference is less than 30 days then generate some kind of notification, for example, today is 2018-05-10 and certificate expiry date is 2018-05-30?
|
So show us what you have done to make it happen.
|
which language do you prefer at all?
|
Code:
#!/bin/bash Code:
$ ./plus_30.sh 2018-06-10 |
Quote:
As of late posts like this have been being closed due to a poor question. Especially when they are first posts from new users. While this is your first post, you've been an LQ member for a few months and likely viewing questions a lot. I will leave this question open to allow you to respond to the members with any feedback. Please provide updates to the users who have asked for feedback as well as one who has provided some great guidance in the form of a bash script. |
Quote:
Thanks, Ginola for the help. I will try this script to see if this works according to my requirement. But since I have just started working with shell scripts I do not know how do I use below lines in my code: Code:
$ ./plus_30.sh 2018-06-10 Can you please help regarding this? |
Quote:
|
Quote:
|
Quote:
|
Hi all,
I found a command which helped me: echo $((($(date -u -d certificate expiry date in yyyy-mm-dd format[/B] +%s) - $(date -u -d current date in yyyy-mm-dd format +%s)) / 86400)). The output of this command gives the difference between two dates in terms of days. |
Quote:
check this out... https://www.shellscript.sh/ HTH. |
Quote:
|
All times are GMT -5. The time now is 06:00 PM. |