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.
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