Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
Was very busy lately working on a new project for a client. One of the key requirements in the project is to create a micro service to poll from external data sources for every two minutes, from 8am to 6pm, Monday to Friday and update the database with the latest data.
After testing out my Go program. I need to put in a crontab to start polling the data.
From the Linux Crontab configuration, the parameters are in such order :
MIN HOUR DOM MON DOW CMD
Explanation:
MIN - Minute field and can be 0 to 59
HOUR - Hour field and can be 0 to 23
DOM - Day of Month and can be 1-31
MON - Month field and can be 1-12
DOW - Day Of Week and can be 0-6
CMD - Comman to be executed.
Therefore, to achieve my objective, the final crontab configuration should look like this :
*/2 08-18 * * 1-5 /microservices/go-poll-and-update-summary-data
Hope this helps!
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+4.8k Golang : Error handling methods
+11.1k Golang : Get month name from date example
+14.2k Golang : Get checkbox or extract multipart form data value example
+32.3k Golang : All update packages with go get command
+9.9k Android Studio : Create custom icons for your application example
+11.4k Golang : "https://" not allowed in import path
+15.4k Golang : How to implement two-factor authentication?
+5.8k Golang : Output or print out JSON stream/encoded data
+4.6k Unix/Linux/MacOSx : Get local IP address
+5k Golang : How to write backslash in string?
+15.3k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+20k Golang : GORM create record or insert new record into database example