I'm making calls to an API, which is constantly fetching me data. There is a limited number of calls that I can make per 15 mins. Can I automate the whole process, and keep the script running for like 24 hours, which executes a certain command at the interval of 15 mins?
Usual alternatives:
a) use "cron" to trigger the script periodically.
b) finish the script with one "at" command, to reschedule it.
c) a never ending loop, as the loop in @VikasYadav answer. However, this solution has the problem of stop working after system restart or script crash. It should be complete with some "keep alive" configuration (/etc/inittab or similar).
You can use something like this:
while(true)
do
# write your bash command to fetch API response using GET api_endpoint_url
sleep 15m
done
I hope this might serve the purpose!
Edit your crontab with the following command:
# crontab -e
Add the following line at the end of crontab:
*/15 * * * * /path/to/your/command.sh
That will run your command every 15 minutes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.