Check if a GPG key will expire soon.
gpg-expiration needs a key ID, or other uniquely identifying search term;
gpg --list-keys SEARCH_TERM
should return exactly one key.
gpg-expiration also takes an interval, specified in days. If the key (or any of its subkeys) expires within that interval, it will print the primary UID and the expiration date(s), then exit with a return code of 1. If not, it will silently exit with a return code of 0.
$ ./gpg-expiration.py --days 30 2B38BD955557647E7C26B53C19E27469767CFC68
Add it as a cron job:
$ crontab -e
# m h dom mon dow command
0 12 * * Mon ~/dev/gpg-expiration/gpg-expiration.py --days 30 2B38BD955557647E7C26B53C19E27469767CFC68
gpg-expiration depends on the official GPGME Python bindings.
The Python bindings are available in the Debian package python3-gpg:
$ sudo apt install python3-gpg