Cron format to run something every ten minutes, but not on the hour?
I thought I had this sussed:- 3/10 * * * * news <command> to run <command> every ten minutes starting at three minutes past the hour but it doesn't. It just runs the command at three minutes past the hour and not again until three minutes past the next hour. (Note this is in a file in /etc/cron.d, hence the 'news' for the username to run the command.) I thought that the first time I set this up it worked every ten minutes, but looking at my logs it seems I was wrong, oh well. I have to admit re-reading the man page I can't see how I expected it to work the way I thought. So I can change it to:- */10 * * * * news <command> but that means (presumably) that the command will run on the hour which I'd really prefer to avoid. Is there no way to say run at x minutes past and every ten minutes thereafter? I suppose I could do:- 3,13,23,33,43,53 * * * * news <command> Is that the only/best way to do it? -- Chris Green
Not test: 3-59/10 should do what you want.
Keith Edmunds wrote:
Not test:
3-59/10 should do what you want.
I suspect that will just run the script at 10,20,30,40 and 50 minutes into each hour. As I always sort of understood the / in cron to be a divide by and pass if the remainder is 0. Sorry Chris I don't have an answer, I just think this one might be wrong :)
On Tue, Oct 20, 2009 at 08:54:57AM +0100, Keith Edmunds wrote:
On Mon, 19 Oct 2009 22:52:40 +0100, ALUGlist@digimatic.co.uk said:
Sorry Chris I don't have an answer, I just think this one might be wrong :)
Why not try it?
Yes, I will, and will come back with the result. -- Chris Green
On 20 Oct 09:25, Chris G wrote:
On Tue, Oct 20, 2009 at 08:54:57AM +0100, Keith Edmunds wrote:
On Mon, 19 Oct 2009 22:52:40 +0100, ALUGlist@digimatic.co.uk said:
Sorry Chris I don't have an answer, I just think this one might be wrong :)
Why not try it?
Yes, I will, and will come back with the result.
Given this line in the manpage for crontab (man 5 crontab): Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9". I'd suggest that it (a) works, and (b) is the correct way without having to specify all the runtimes. -- Brett Parker
On Tue, Oct 20, 2009 at 09:55:53AM +0100, Brett Parker wrote:
On 20 Oct 09:25, Chris G wrote:
On Tue, Oct 20, 2009 at 08:54:57AM +0100, Keith Edmunds wrote:
On Mon, 19 Oct 2009 22:52:40 +0100, ALUGlist@digimatic.co.uk said:
Sorry Chris I don't have an answer, I just think this one might be wrong :)
Why not try it?
Yes, I will, and will come back with the result.
Given this line in the manpage for crontab (man 5 crontab): Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9".
I'd suggest that it (a) works, and (b) is the correct way without having to specify all the runtimes.
Yes, it does work, I now have:- 3-59/10 * * * * news blahblah and it's running at 03, 13, etc. I searched and searched for that bit in the man page as I was pretty sure I'd seen it before but for some reason I couldn't find it when I looked for it the second time. It's down in the EXTENSIONS bit at the end which, for some reason, I missed second time around. (I had it working then re-installed the leafnode package and lost my original entry in /etc/cron.d. Then, as I said, I couldn't find the bit I had seen before in man 5 crontab!) Thanks all. -- Chris Green
participants (4)
-
Brett Parker -
Chris G -
Keith Edmunds -
Wayne Stallwood