5

I know I can do simple arithmetic in shell scripts, like so:

#!/bin/bash
((sum = 1 + 2))
echo sum

This will output 3 on execution. My question now is, can this kind of expressions be used in crontab? For example, see this line:

03,13,23,33,43,53 * * * * ~/DoSomeStuff.sh

The minutes could be specified as x+3 with x the expression */10, which can be used in crontabs. However, simply writing */10+3 or ((*/10+3)) won't work. Is there any way to do this? And what is the correct syntax?

The alternative, that certainly works, is putting a sleep 3m. I'm just wondering if the arithmetic way of doing it is somehow possible.

1
  • You mean: x minutes after y?
    – Braiam
    Jul 7, 2014 at 14:02

1 Answer 1

7

From Wikipedia:

Slash ( / )

Slashes describe increments of ranges. For example 3-59/15 in the 1st field (minutes) indicate the third minute of the hour and every 15 minutes thereafter. The form "*/..." is equivalent to the form "first-last/...", that is, an increment over the largest possible range of the field.

So 3-59/10 * * * * ~/DoSomeStuff.sh should be what you're looking for.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .