5 4 * * 1 test $(($(date +%W)%2)) -eq 1 && your_command
Ok, the tricky part to make it run every two weeks is to know what day of the week is the first 2nd. Let's imagine it is a Monday, this monday, and this week (number 13). We we'll focus on make it run every second monday.
5 4 * * 1 Every monday script or command works at 04:05
$(($(date +%W)%2)) Evaluates the numeric week expresion and gets his module (1 odd or 0 par)
test $(($(date +%W)%2)) -eq 1 True if the week is odd, we avoid par weeks. We can change it to -eq 0 in case of need it to work on par weeks
&& your_command If the previous condition works, your script or command runs
ruby-on-railsandruby– do you want to build the crontab line(s) programmatically? - Stefan