Skip to content

Instantly share code, notes, and snippets.

@VADemon
Last active May 14, 2019 23:21
Show Gist options
  • Save VADemon/9e346773b83f7ccdc8976ba697b672ff to your computer and use it in GitHub Desktop.
Save VADemon/9e346773b83f7ccdc8976ba697b672ff to your computer and use it in GitHub Desktop.
Bash/Cron: check last day of month / new or next month
#!/bin/bash
# for more info, escape chars in cron etc:
# https://unix.stackexchange.com/questions/89188/cron-allowed-special-character-l-for-last-day-of-the-month-on-debian
[ "$(date -d 'tomorrow' +%d)" == "01" ] && echo "next month" || echo "same month"
# UPD: found same solution https://stackoverflow.com/a/6139310/1599009
# exit code?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment