How to monitor certificate expiry date using a linux script
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to monitor certificate expiry date using a linux script
Hi,
I face a problem to compare time and date. I need to convert the format of the output of "date" command with the following default format:
Mon Apr 27 02:29:57 EST 2009
to the following Format:
Apr 27 02:29:57 2009 GMT
The purpose of this is to design a script to monitor if a certificate expires or not. The latest format "Apr 27 02:29:57 2009 GMT" is the date format of the certificate which I cannot compare with "date".
How can I compare if it is expired? can you help me please ?
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197
Rep:
Try checking out `man convdate`. Put both in the form of seconds since the epoch, and then do a simple numerical comparison.
Alternatively, mon (http://mon.wiki.kernel.org/index.php/Main_Page) has a monitor module that checks web certs for expiration. With terms like "mon" and "monitor", that can be wickedly difficult to google. So, I have to remember "kernel.org" to even find them, and then follow links from there or ask on their mailing list. However, I particularly like mon for its simplicity -- http://blogs.umass.edu/choogend/2007...nitoring-tool/
The time difference is in seconds and 0 if there is no time difference. Note that these expression currently do not take DST into account, because I don't have tz_dsttime set on my computer. Maybe you should check that yourself on your own computer.
Try checking out `man convdate`. Put both in the form of seconds since the epoch, and then do a simple numerical comparison.
Alternatively, mon (http://mon.wiki.kernel.org/index.php/Main_Page) has a monitor module that checks web certs for expiration. With terms like "mon" and "monitor", that can be wickedly difficult to google. So, I have to remember "kernel.org" to even find them, and then follow links from there or ask on their mailing list. However, I particularly like mon for its simplicity -- http://blogs.umass.edu/choogend/2007...nitoring-tool/
The time difference is in seconds and 0 if there is no time difference. Note that these expression currently do not take DST into account, because I don't have tz_dsttime set on my computer. Maybe you should check that yourself on your own computer.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.