Scheduling api

rm11
Participant I

Hi all,

Do we have any approach to call api at regular intervals without using node.

0 6 574
6 REPLIES 6

Not applicable

Hi Reshma,

You can do it using cron job in linux. Create a script file and place a curl command in that file. Configure a schedule to call api at regular intervals.

Thanks Muhammad.

But can you provide example how to do it

Not applicable
I am using Centos 7 so command may vary depending upon Linux flavor.
Step 1: Create a new file with name script.sh in Linux using a command.
sudo touch script.sh
Step 2: Make file executable using following command
sudo chmod 775 script.sh
Step 3: Open a newly created file with vi editor
sudo vi script.sh
Step 4: Place a curl command in newly created file and save it using :wq command. Sample curl command is attached for your reference.
curl -x GET -u sysAdminEmail:password http://localhost:8080/v1/servers

Step 4: Create Cronjob

sudo crontab -e

Step 5: Add scheduler time and executable file path. Note with below configuration it will run after every 5 seconds. However you can change scheduler time.

*/5 * * * * /usr/bin/script.sh

Step 6: Save it with :wq command. It will create a new job which will execute after every 5 second and run script.sh executable file and we know that it contains curl command which will send call to API.

Thanks,

Can we implement that in apigee?

Not applicable

Well, I might be one of the options if you don't want to use node. You can run this script on the server where apigee installed but it totally depends on the environment and nature of scripts. I am using this technique to take database backups or backend server for every minute just to verify whether it is up or not.

Is there any approach other than this.