Re : How to create this cron job?

Hello All,

Hope this finds you well. I am creating this shell script that will create cron jobs in crontab file. What I am provided with is the start time , intervals and # of trials. Based of Start time ( say 7:15 am ) and interval being 15 minutes, # of trial being 5 , I should create cron job with following time ...

07:15 07:30 07:45 08:00 08:15

now I would create cron job for this time requirement as ...

15,30,45,00 07,08 * * * command.....

But above would also run command at 07:00 , 08:30, 08:45 ....which is not required. I am using Bourne Shell (sh) . Would appreciate your help in this regards. Let me know if I missed on some.

Thanks,
Sam

create the cron job with two lines :

15,30,45 07 * * * command.....
00,15 08 * * * command.....

Hello ThobiasVakayil,

So besides spliting them into 2 lines, there is not other solution ....is this correct ?

Thanks,
Sam

I think it is the solution.
B'cos there is no match between the minutes entry.

Its not possible in any way.
In single line we cant give the timings.
need to put in different lines for each execution on the same field(*).

If you insist on having one line only in cron you could create an intermediary script which starts your job at the correct times using the "at"-command. This script could be invoked by cron. Crontab would look like this:

15 7 * * * * my_startscript.sh

and my_startscript.sh would look like this:

#!/bin/sh

echo "/my/app -options" | at now
echo "/my/app -options" | at now + 15 minutes
echo "/my/app -options" | at now + 30 minutes
echo "/my/app -options" | at now + 45 minutes

exit 0 

I hope this helps.

bakunin