Gentoo Archives: gentoo-user

From: Joseph <syscon780@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] crontab - "and' condition
Date: Sat, 20 Sep 2014 17:40:32
Message-Id: 20140920174022.GA4334@syscon7
In Reply to: Re: [gentoo-user] crontab - "and' condition by "Stephan Müller"
1 On 09/19/14 09:47, Stephan Müller wrote:
2 >Am 18.09.2014 um 18:44 schrieb Joseph:
3 >> I want to run a cron job only once a month. The problem is the computer is only on on weekdays Mon-Fri. 1-5
4 >> cron tab as this below is an "or" condition as it has entries in Days of the Months and Day of the Week
5 >>
6 >> 5 18 1 * 2 rsync -av ...
7 >>
8 >> so it will run on days 1 or Tuesday of each months.
9 >> Is it possible to create "and" condition, eg. run it on Tuesday between days 1 to 7; depend on which day Tuesday falls on?
10 >
11 >You can run it every Tuesday and check for day of month externally:
12 >
13 >5 18 * * 2 test $(date +%d) -le 7 && rsync -av ...
14 >
15 >or run it on
16 >
17 >5 18 1-7 * * and test for Tuesdays, but the former gives less useless invocations.
18 >
19 > ~frukto
20
21 Thanks, very cleaver, I knew there must be a solution.
22
23 --
24 Joseph