Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crontab schedule every two week

Tags:

bash

cron

There is a question happened this week on my crontab job.
It's be set as below and works normal every two weeks until now.

10 06 * * 1 test $(($(date +\%W)\%2)) -eq 0 && echo 'test' > /tmp/test.log

The problem is

$(($(date +\%W)\%2)) would be 08, over 7 in February.

And it will show error message if you run in bash: value too great for base (error token is "08").

There is also not working when I try to revise it for forcing decimal base purpose :

10 06 * * 1 test $((10#$(date +\%W)\%2)) -eq 0 && echo 'test' > /tmp/test.log

Does someone know how to solve this issue?
Many thanks.

like image 832
Jerry Chen Avatar asked Apr 29 '26 01:04

Jerry Chen


1 Answers

Every two week at midnight

   0 0 */15 * * echo 'test'  > tmp.txt


Your cron job will be run at: (5 times displayed)

2016-03-15 00:00:00 UTC
2016-03-30 00:00:00 UTC
2016-04-15 00:00:00 UTC
2016-04-30 00:00:00 UTC
2016-05-15 00:00:00 UTC
like image 110
nguaman Avatar answered Apr 30 '26 14:04

nguaman