0

I want cron to be run in every 55 mins. I followed the link CronJob every 25 minutes

and my crontab command is

*/5 * * * * [ $(( $(date +%s) / 60 % 55 )) -eq 0 ] && wget http://localhost/sandbox/run-cron-job

but I am getting error message in file /var/mail/root

From root@shashikanth-912  Wed May 20 10:55:01 2015
Return-Path: <root@shashikanth-912>
X-Original-To: root
Delivered-To: root@shashikanth-912
Received: by shashikanth-912 (Postfix, from userid 0)
        id DD3CE4006E; Wed, 20 May 2015 10:55:01 +0530 (IST)
From: root@shashikanth-912 (Cron Daemon)
To: root@shashikanth-912
Subject: Cron <root@shashikanth-912> [ $(( $(date +
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
Message-Id: <20150520052501.DD3CE4006E@shashikanth-912>
Date: Wed, 20 May 2015 10:55:01 +0530 (IST)

/bin/sh: 1: Syntax error: end of file unexpected (expecting ")")

How to fix this problem.

  • According to this: cyberciti.biz/faq/crontab-every-10-min you should be able to do just */55 * * * * /path/to/command – Joshua Terrill May 20 '15 at 5:48
  • What does it mean to be "run in every 55 minutes"? Does that mean that within any 55 minute interval of a day it is run at least once? Exactly once? – Anthon May 20 '15 at 5:50
  • 2
    You need to escape the % with backslash (% has a special meaning in crontab entries) – Stéphane Chazelas May 20 '15 at 6:21
  • @JoshuaTerrill, that runs the command at 1:00, 1:55, 2:00, 2:55, etc. */10 works ok because 60 is divisible by 10. It's not divisible by 55. – cjm May 20 '15 at 6:49
  • @Anthon : "run in every 55 minutes" means run cron at 1:00, 1:55, 2:50, 3:45, 4:40 ..... – shashikant May 20 '15 at 8:47
0

@Stéphane Chazelas, Thanks for suggestion. I escaped the % with backslash. now its working. Working crontab command is

*/5 * * * * [ $(( $(date +\%s) / 60 \% 55 )) -eq 0 ] && wget http://localhost/sandbox/run-cron-job

Not the answer you're looking for? Browse other questions tagged or ask your own question.