Last active
March 2, 2016 12:30
-
-
Save lillesvin/dd73a92441e19e6a4162 to your computer and use it in GitHub Desktop.
Hack to run bi-weekly jobs via Cron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hack to run every 2nd Tuesday: | |
# - Cron notation to run every Tuesday | |
# - PHP exits with (effectively): date("W") % 2 | |
# - Hacked to remove all '%' because cron can't handle them | |
# - Use shell chaining (&& and ||) to determine even/odd weeks | |
# - && for even week numbers, || for odd | |
# So to run `echo "Still here ..."` every other Tuesday at 10:30 AM: | |
30 10 * * 2 php -r 'exit((int)fmod(date("W"),2));' && echo "Still here ..." | |
# Note: PHP can obviously be replaced with anything that | |
# can be executed in a similar fasion and doesn't contain | |
# percentage signs (%), e.g. Ruby: | |
# `ruby -rdate -e 'exit (Date.today.cweek.modulo(2))'` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment